We're merging with GenerateBlocks! Learn more here.

[Support request] Excluded posts still appear

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Excluded posts still appear

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27600
    Sam
    Participant

    I have set up a side bar widget which displays 3 WP-SHOW-POST

    1 – Pinned top posts (set up by adding Post ID to list
    2 – Recent post (last x posts)
    3 – Random for category

    I have tried adding the post IDs for the pinned to the other two WP-SHOW-POSTs (ie 2 and 3) but they keep being displayed

    Is there a issue or have just done something wrong

    (how can I send you my website URL. If I post it here, I will get nofollow back link)

    #27603
    elvin
    Moderator

    Hi,

    Can you tell what version of WordPress and WP Show Posts plugin are you using? To attempt to replicate the issue.

    To clarify: I believe you’re trying to prevent the multiple WP Show Posts from displaying duplicate posts?

    Let us know.

    You can send it through our contact page found here: https://wpshowposts.com/contact/

    #27661
    Sam
    Participant

    Hi

    I am using WPSHOW 1.1.3 and GP (current full release)

    I have set up staging site as I didn’t want duplicate content being shown

    And in response to you question, Yes. Three WPSHOWPOST item with a side widget, which is shown on all posts

    The first will be 2 pinned post, ie i have stated the post ID in the setup.

    The other two, I am have added those same post IDs to the exclude section – but they are still being displayed.

    I have sent the URL via contact – if you want access to WP-admin I can set you up an account.

    #27667
    Sam
    Participant

    WordPress 5.7

    #27750
    elvin
    Moderator

    I’m not exactly sure if this will fit what you’re looking for but try this code:

    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);
    }

    This particular code removes existing posts on the other list if it exists on the one list.

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