Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Duplicate Homepage Content

  • Hello,

    I’ve been working with chatGPT, which has been unable to solve a problem I have with a site under development.

    The homepage contains an article that appears 7 times. We are working with a child template of Generate Press that was created for other purposes but progress has been terribly slow.

    I’m just wondering if the Generate Press coders considered adding code to check for – and remove or prevent – duplicate content from appearing on Posts/Pages? If so, I would greatly appreciate learning how to turn on duplicate content checking.

    Thanks,
    Jason

  • Hi there,

    can I see the homepage so I have some idea of its structure and if its possible to remove duplicate posts.

  • Hello,

    Visit https://test.itechguide.com. Note the article Artificial Intelligence Programming appears 7 times on the homepage.

    Thanks,
    Jason

  • Hi there,

    Have you configured these query loop blocks?

    For example, have you added offset parameters to the query loops, so they can skip a certain number of posts?

  • Hi Ying,

    I’m a c++/python programmer so we perhaps have a terminology difference. Sorry for my lack of WordPress knowledge.

    I did edit the query loops, with inherit query from template turned off, to select post type=posts, post per page=2, taxonomies=categories, select terms=#7: Ai but this is not giving me the granularity of control that I desire. I know its possible to continue to add additional parameters but I’m not sure which? Would I just add a second taxonomy for the same category using exclude to prevent additional copies of the same article? I just need to know the correct sequence of options.

    It might also be advantageous to encode a function that can be enabled to prevent duplication of content on a single page. I’ve observed other Generate Press users experiencing this issue.

    Thanks,
    Jason

  • The ideal scenario is to configure each query loop, however, if your posts are assigned to multiple categories, it might still create the duplication issue even with the query loop set to different categories.

    However, give this PHP function a try:

    add_filter('post_link', 'track_displayed_posts');
    add_action('pre_get_posts', 'remove_already_displayed_posts', 2);
    
    $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) {
        if (!is_admin()) {
            global $displayed_posts;
            if (!empty($displayed_posts)) {
                $query->set('post__not_in', $displayed_posts);
            }
        }
    }

    Let me know if this helps!

  • Thank you very much!

  • You are welcome   🙂

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