1

I am wanting to add this code to single blog posts only after content. Right now it is showing up on every page after content.

add_action( 'presscore_after_content', 'insert_cp_banner' );

function insert_cp_banner() {
    rcblock_by_id( "8301" );
}

2 Answers 2

1

Add the check for a single post:

if ( is_single() && 'post' == get_post_type() ) {

 add_action( 'presscore_after_content', 'insert_cp_banner' );
}

See this for details: https://developer.wordpress.org/reference/functions/is_single/

0

You could try this

add_action( 'presscore_after_content', 'insert_cp_banner_after_content' );

function insert_cp_banner_after_content() {

    $banner_id = '1111'; //Use the default banner if not a single post type

    if ( is_singular( 'post' ) ) {
        $banner_id = '8301';
    }

    rcblock_by_id( $banner_id );
}

With this approach, you can effortlessly include various banners based on the post type or page and have a fallback option to use a default banner when needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.