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

Home Forums Support [Resolved] Making 3-4 posts be at the top or archive, but different ones depending

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

Viewing 7 posts - 31 through 37 (of 37 total)
  • Author
    Posts
  • #1904007
    nomadiceman

    Thank you 🙏

    #1904039
    Tom
    Lead Developer
    Lead Developer

    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.

    #1904062
    nomadiceman

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

    #1904063
    nomadiceman

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

    #1904481
    David
    Staff
    Customer Support

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

    #1904695
    nomadiceman

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

    #1905185
    David
    Staff
    Customer Support

    Yeah the method we used here isn’t going to work if the duplicates are not on the same page as the WPSP list.
    You would need to use the Method that Tom provided here:

    https://generatepress.com/forums/topic/making-3-4-posts-be-at-the-top-or-archive-but-different-ones-depending/page/3/#post-1904039

Viewing 7 posts - 31 through 37 (of 37 total)
  • You must be logged in to reply to this topic.