• Hi i have problems with my site due to duplicate posts.

    I know that the following code compensates for the number of articles shown in highlights to avoid duplication.

    add_filter( 'pre_get_posts', function( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $offset = 4;
            $ppp = get_option('posts_per_page');
    
            if ( $query->is_paged ) {
                $page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
                $query->set('offset', $page_offset );
            } else {
                $query->set('offset',$offset);
            }
        } else {
            return $query;
        }
    } );

    The problem is that this does not help me because in the WP Show Post grid I am only showing articles from 2 specific categories. So the above code removes the articles that you shouldn’t delete because they were never in the WP Show Post grid. I have tried to adapt the filter above so that it only removes 4 items from the list that always belong to the category I have in the WP Show Post grid, but I can’t get it to work, my knowledge of PHP is very basic.

    My site web is: https://cutt.ly/EniZHH0 In the Home you can see the duplicate articles.

    Is there a solution to this? Thanks a lot!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Articles duplicade’ is closed to new replies.