Site logo

Archived topic

Making 3-4 posts be at the top or archive, but different ones depending

36 replies · Started by nomadiceman on August 11, 2021

Viewing posts 31–37 of 37

Thank you 🙏

This method only works if the WPSP list is displayed on the page. It's not on the paginated page, so the code doesn't know to exclude it from the archives.

If you know the IDs of the posts you want to exclude, you might be able to get away with just this:

add_filter( 'generate_do_template_part', function( $do ) {
    $excluded_post_ids = array( 1, 2, 3 );

    if ( in_array( get_the_ID(), (array) $excluded_post_ids )) {
        $do = false;
    }

    return $do;
} );

Just replace the 1, 2 and 3 with the IDs you've manually set in your WPSP list.

Ah ok. Thanks Tom. I’ll give that a try.

It’s interesting as 2 of the posts gave been excluded with the code you say shouldn’t work

Were those 2 posts on the front Page of the archive ? ie. where the WPSP featured posts are present.

Hi David. Yes the 2 that gave been excluded were earlier posts and was still on page 1

This archived topic is closed to new replies.