[Resolved] hide post display already magazine grid on the blog page

Home Forums Support [Resolved] hide post display already magazine grid on the blog page

Home Forums Support hide post display already magazine grid on the blog page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1631273
    SEBASTIEN

    hello, I am very happy to use generate press for my projects, I have a question especially concerning the theme dispatch with the magazine grid.

    I use this little function to remove the posts already published on my home page, keeping the main article in the grid magazine, but this does not work on my blog category page, can you direct me ?

    //hide posts which have been displayed already
    add_filter(‘post_link’, ‘track_displayed_posts’);
    add_action(‘pre_get_posts’,’remove_already_displayed_posts’);

    $displayed_posts = [];

    function track_displayed_posts($url) {
    global $displayed_posts;
    $displayed_posts[] = get_the_ID();
    return $url; // don’t mess with the url
    }

    function remove_already_displayed_posts($query) {
    global $displayed_posts;
    $query->set(‘post__not_in’, $displayed_posts);
    }

    #1631544
    David
    Staff
    Customer Support

    Hi there,

    can you share a link to a Category page where i can see the issue?

    #1632930
    SEBASTIEN

    it’s resolved, I needed to do set( ‘offset’, ‘4’ ); for is_archive.

    but maybe there is a better solution?

    see ya

    Seb

    #1632987
    David
    Staff
    Customer Support

    Thats a valid solution. The only issue you may have is if it is used on a paginated archive, as WP doesn’t handle offset very well in that instance.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.