Skip to content
Public Ticket #17299

advertising

Conversation thread

PenciDesign Supporter replied

Staff Reply

Hi,

By default, the category ads code only display on the magazine template, if you want to display it on the category page, please go to Appearance → Theme Editor, open file functions.php, find line 2973:

if ( ! function_exists( 'penci_render_google_adsense' ) ) {
    function penci_render_google_adsense( $option ) {
        if( ! get_theme_mod( $option ) )
            {return '';}
        return '<div class="penci-google-adsense '. $option .'">'. do_shortcode( get_theme_mod( $option ) ) .'</div>';
    }
}

Replace with this content:

if ( ! function_exists( 'penci_render_google_adsense' ) ) {
    function penci_render_google_adsense( $option ) {
        $ads_code = get_theme_mod( $option );
        if ( is_category() && 'penci_archive_ad_above' == $option  ) {
            $cat_id    = get_queried_object()->term_id;
            $cat_meta  = get_option( "category_$cat_id" );
            $ads_code  = isset( $cat_meta['mag_ads'] ) ? stripslashes( $cat_meta['mag_ads'] ) : $ads_code;
        }
        if ( $ads_code ) {
            return '<div class="penci-google-adsense '. $option .'">'. do_shortcode( $ads_code ) .'</div>';
        } else {
            return false;
        }
    }
}

Update file then reload your site.

Regards,
PenciDesign.

PenciDesign Supporter replied

Staff Reply

Hi,

Please access your dashboard, then go to Posts → Categories, click edit on the category you want to insert custom ads, then put the Ads code at Add Google Adsense/Custom HTML Code below this category field.

image.png

Regards,
PenciDesign.


bonus17 started the conversation

Conversation Start

I would like a different advertising banner to appear in each category.

Example: Category 1 has a sponsor number 1 - this sponsor's ads are displayed only for Category 1. Category 2 has a different sponsor, so other ads are needed there. How does any html code anywhere on a category page? Do I have to create an elementor template or is there a faster way to do it?

Want to join this conversation or access attachments? Sign in first.