Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Stop showing duplicate posts on the same page/post using a different shortcode Reply To: Stop showing duplicate posts on the same page/post using a different shortcode

#15716
Tom
Keymaster

That looks promising! Let’s try this:

add_filter( 'wp_show_posts_shortcode_args', function( $args ) {
    global $added_ids;

    // Exclude posts that have already been added.
    $args['post__not_in'] = $added_ids;

    return $args;
} );

add_action( 'wpsp_before_header', function() {
    global $added_ids;

    $added_ids[] = get_the_ID();
} );