• User Attivo

    @Ultima said:

    Visto che non hai il file archive.php ( non capisco il motivo ), tutto viene gestito dal file index.php, quindi: tag, archivi, categorie etc
    Sicuramente all'interno di index, avrai dei richiami alla cartella templates.
    Individuato il loop di layout corretto non ti rimane che scrivere una piccola condizione:

    >
    if( is_category() && !is_home() && !is_single() && !is_archive() ) : 
    // inserisci banner o fai quello che vuoi
    endif;
    
    >```
    
    ho provato quasi in tutti i file del tema ma nulla non funziona....ci rinuncio....
    
    ti ringrazio tanto per la tua disponibilità ed il tempo dedicato al mio Topic ;-)

  • Moderatore

    È impossibil3 non trovare una soluzione. Che template stai utilizzando? Se posso scaricarlo ti mostro esattamente come fare


  • User Attivo

    @Ultima said:

    È impossibil3 non trovare una soluzione. Che template stai utilizzando? Se posso scaricarlo ti mostro esattamente come fare

    il tema è questo:

    mhthemes.com/lite/?theme=magazine_lite

    questa è la versione lite liberamente scaricabile io ho la versione premium che ha più opzioni ma tutto il resto è uguale...

    ti ringrazio per la disponibilità....


  • Moderatore

    Dunque, sperando il template cambi di poco, alla riga 195 del file functions.php trovi questo codice:

    [PHP]
    if (!function_exists('mh_page_title')) {
    function mh_page_title() {
    if (!is_front_page()) {
    echo '<div class="page-title-top"></div>' . "\n";
    echo '<h1 class="page-title">';
    if (is_archive()) {
    if (is_category() || is_tax()) {
    single_cat_title();
    } elseif (is_tag()) {
    single_tag_title();
    } elseif (is_author()) {
    global $author;
    $user_info = get_userdata($author);
    printf(_x('Articles by %s', 'post author', 'mh'), esc_attr($user_info->display_name));
    } elseif (is_day()) {
    echo get_the_date();
    } elseif (is_month()) {
    echo get_the_date('F Y');
    } elseif (is_year()) {
    echo get_the_date('Y');
    } else {
    _e('Archives', 'mh');
    }
    } else {
    if (is_home()) {
    echo get_the_title(get_option('page_for_posts', true));
    } elseif (is_404()) {
    _e('Page not found (404)', 'mh');
    } elseif (is_search()) {
    printf(('Search Results for %s', 'mh'), esc_attr(get_search_query()));
    } else {
    the_title();
    }
    }
    echo '</h1>' . "\n";
    }
    }
    }
    add_action('mh_before_page_content', 'mh_page_title');
    [/PHP]
    Io l'ho editato in questo modo:
    [PHP]
    if (!function_exists('mh_page_title')) {
    function mh_page_title() {
    if (!is_front_page()) {
    echo '<div class="page-title-top"></div>' . "\n";
    echo '<h1 class="page-title">';
    if (is_archive()) {
    if (is_category() || is_tax()) {
    single_cat_title();
    echo 'div class="banner">';
    echo 'inserisci qui il tuo codice banner';
    echo '</div>';
    } elseif (is_tag()) {
    single_tag_title();
    } elseif (is_author()) {
    global $author;
    $user_info = get_userdata($author);
    printf(_x('Articles by %s', 'post author', 'mh'), esc_attr($user_info->display_name));
    } elseif (is_day()) {
    echo get_the_date();
    } elseif (is_month()) {
    echo get_the_date('F Y');
    } elseif (is_year()) {
    echo get_the_date('Y');
    } else {
    _e('Archives', 'mh');
    }
    } else {
    if (is_home()) {
    echo get_the_title(get_option('page_for_posts', true));
    } elseif (is_404()) {
    _e('Page not found (404)', 'mh');
    } elseif (is_search()) {
    printf(
    ('Search Results for %s', 'mh'), esc_attr(get_search_query()));
    } else {
    the_title();
    }
    }
    echo '</h1>' . "\n";
    }
    }
    }
    add_action('mh_before_page_content', 'mh_page_title');
    [/PHP]

    Prova così e vedi se ora funziona 🙂
    Ovviame dove io ho scritto inserisci qui il tuo codice, dovrai inserire il codice di adsense, stando attendo alla punteggiatura, visto che lo stai facendo scrivere a PHP


  • User Attivo

    inserisco il codice adsense solo ? gli apici li lascio o vanno rimossi ???


  • Moderatore

    hai un po' di dimestichezza con PHP?
    dovresti inserire il codice all'interno del mio echo '', ovvero all'interno di quegli apici.
    Puoi anche adottare una soluzione meno problematica che è questa:

    [PHP]
    if (!function_exists('mh_page_title')) {
    function mh_page_title() {
    if (!is_front_page()) {
    echo '<div class="page-title-top"></div>' . "\n";
    echo '<h1 class="page-title">';
    if (is_archive()) {
    if (is_category() || is_tax()) {
    single_cat_title();
    echo 'div class="banner">'; ?>
    CODICE BANNER QUI
    <?php

                    echo '</div>';
                } elseif (is_tag()) {
                    single_tag_title();
                } elseif (is_author()) {
                    global $author;
                    $user_info = get_userdata($author);
                    printf(_x('Articles by %s', 'post author', 'mh'), esc_attr($user_info->display_name));
                } elseif (is_day()) {
                    echo get_the_date();
                } elseif (is_month()) {
                    echo get_the_date('F Y');
                } elseif (is_year()) {
                    echo get_the_date('Y');
                } else {
                    _e('Archives', 'mh');
                }
            } else {
                if (is_home()) {
                    echo get_the_title(get_option('page_for_posts', true));
                } elseif (is_404()) {
                    _e('Page not found (404)', 'mh');
                } elseif (is_search()) {
                    printf(__('Search Results for %s', 'mh'), esc_attr(get_search_query()));
                } else {
                    the_title();
                }
            }
            echo '</h1>' . "\n";
        }
    }
    

    }
    add_action('mh_before_page_content', 'mh_page_title');
    [/PHP]


  • Moderatore

    News? Ha funzionato?


  • User Attivo

    ciao in pratica nel file functions della versione premium non c'è ma è in un'altro file mh-content.php ed il codice è un po diverso ecco la struttura:

    /***** Loop Output *****/

    if (!function_exists('mh_loop')) {
    function mh_loop() {
    global $post, $paged, $options;
    $do_not_duplicate[] = '';
    $counter = 0;
    $layout = isset($options['loop_layout']) ? $options['loop_layout'] : 'layout1';
    $adcode = empty($options['loop_ad']) ? '' : '<div class="loop-ad loop-ad-' . $layout . '">' . do_shortcode($options['loop_ad']) . '</div>' . "\n";
    $adcount = empty($options['loop_ad_no']) ? '3' : $options['loop_ad_no'];
    if (is_category() && $paged < 2 && isset($options['loop_slider']) && $options['loop_slider'] != 'no_slider') {
    $category = single_cat_title("", false);
    $cat_id = get_cat_ID($category);
    $cat_meta = get_option("category_$cat_id");
    $cat_postcount = isset($cat_meta['slider_postcount']) ? $cat_meta['slider_postcount'] : '5';
    $cat_posts = new WP_Query('showposts=' . intval($cat_postcount) . '&cat=' . $cat_id);
    if ($cat_posts->have_posts()) {
    get_template_part('/templates/loop-slider', get_post_format());
    while($cat_posts->have_posts()) : $cat_posts->the_post(); $do_not_duplicate[] = $post->ID; endwhile;
    }
    }
    if (have_posts()) {
    echo '<div class="loop-content clearfix">' . "\n";
    while (have_posts()) : the_post(); if (in_array($post->ID, $do_not_duplicate)) continue;
    get_template_part('/templates/loop-' . $layout, get_post_format());
    if ($counter % $adcount == 0) {
    echo $adcode;
    }
    $counter++;
    endwhile;
    echo '</div>' . "\n";
    mh_pagination();
    } else {
    get_template_part('content', 'none');
    }
    }
    }
    add_action('mh_loop_content', 'mh_loop');

    /***** Loop Output Meta Data *****/

    if (!function_exists('mh_loop_meta')) {
    function mh_loop_meta() {
    global $options;
    $post_date = isset($options['post_meta_date']) ? !$options['post_meta_date'] : true;
    $post_comments = isset($options['post_meta_comments']) ? !$options['post_meta_comments'] : true;
    if ($post_date || $post_comments) {
    echo '<p class="meta">';
    if ($post_date) {
    echo get_the_date();
    }
    if ($post_date && $post_comments) {
    echo ' // ';
    }
    if ($post_comments) {
    comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh'));
    }
    echo '</p>' . "\n";
    }
    }
    }

    ?>

    credo che sia qui che andrebbe inserito il tutto....


  • Moderatore

    Prova ad inserire il codice appena sotto
    [PHP]
    if( is_category() ...
    [/PHP]


  • User Attivo

    intendi solo in codice adsene o il tuo codice editato ?

    lo inserisco subito dopo questa riga ?

    [PHP]if (is_category() && $paged < 2 && isset($options['loop_slider']) && $options['loop_slider'] != 'no_slider') {[/PHP]


  • User Attivo

    ho inserito il seguente codice dopo quella riga

    [PHP]
    echo 'div class="banner">';
    echo '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
    style="display:inline-block;width:336px;height:280px"
    data-ad-client=""
    data-ad-slot="6911572934"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>';
    echo '</div>';
    [/PHP]

    ma nulla non visualizza nessun banner....

    ho provato anche a spostare tutto il codice dopo la riga

    [PHP]$category = single_cat_title("", false);[/PHP]

    che dovrebbe essere il titolo della categoria, ma comunque non visualizza nulla....


  • User Attivo

    quella parte di codice che tu inizialmente hai modificato l'ho trovata in un'altro file eccola:

    [PHP]
    /***** Page Title Output *****/

    if (!function_exists('mh_page_title_output')) {
    function mh_page_title_output() {
    global $options;
    $layout = isset($options['page_title_layout']) ? $options['page_title_layout'] : 'layout1';
    if (!is_front_page()) {
    if ($options['page_title_layout'] == 'layout1') {
    echo '<div class="page-title-top"></div>' . "\n";
    }
    echo '<h1 class="page-title page-title-' . $options['page_title_layout'] . '">';
    mh_page_title();
    echo '</h1>';
    }
    }
    }
    add_action('mh_before_page_content', 'mh_page_title_output');

    if (!function_exists('mh_page_title')) {
    function mh_page_title() {
    if (is_home()) {
    echo get_the_title(get_option('page_for_posts', true));
    } elseif (is_author()) {
    global $author;
    $user_info = get_userdata($author);
    echo __('Articles by ', 'mh') . esc_attr($user_info->display_name);
    } elseif (is_category() || is_tax()) {
    echo single_cat_title("", false);
    } elseif (is_tag()) {
    echo single_tag_title("", false);
    } elseif (is_search()) {
    echo __('Search Results for ', 'mh') . get_search_query();
    } elseif (is_day()) {
    echo get_the_date();
    } elseif (is_month()) {
    echo get_the_date('F Y');
    } elseif (is_year()) {
    echo get_the_date('Y');
    } elseif (is_404()) {
    echo __('Page not found (404)', 'mh');
    } else {
    echo get_the_title();
    }
    }
    }
    [/PHP]

    ho provato ad inserire il seguente codice dove tu mi hai indicato:

    [PHP]
    echo 'div class="banner">';
    echo '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
    style="display:inline-block;width:336px;height:280px"
    data-ad-client=""
    data-ad-slot="6911572934"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>';
    echo '</div>';
    [/PHP]

    il banner adsense viene visualizzato pero di fianco al titolo della categoria compare anche una porzione di codice questa

    [PHP]
    'div class="banner">'
    [/PHP]

    e la sidebar del tema scompare e viene riportata alla fine del Tema....

    diciamo che abbiamo individuato il punto dove inserire il codice, però c'è qualcosa da aggiustare 🙂


  • Moderatore

    Primo dettaglio: aggiungi il tag di apertura del div ( < ), cosi da diventare: <div class="banner">
    Poi lo stile ed il suo corretto posizionamento, lo dai attraverso il css:
    .banner {
    regole css
    }


  • User Attivo

    Ciao sono stato fuori ed ho provato solo oggi, in pratica non mi ero accorto che mancava il tag di apertura...

    non c'è stato bisogno di inserire nessuna regola nel file .css in effetti la sidebar veniva spostata alla fine della pagina a causa del tag mancante....

    ti ringrazio davvero tanto per avermi aiutato a fare questa modifica, che magari è semplice per chi è esperto ma non lo è per chi invece un'esperto non lo è !!!!