We're merging with GenerateBlocks! Learn more here.

[Support request] Show Related Posts & Exclude Post

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Show Related Posts & Exclude Post

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #18717
    Connor
    Participant

    Hey Tom,

    I have what I believe to be two very simple questions (I hope).

    First, I have WP Show Posts set up to show 3 posts at the bottom of each blog post. My questions are as follows:

    1. I want to only show posts that are in the same category as the blog post. So, for example, if a blog post is in the budgeting category, I want the three posts shown by WP Show Posts to be in the Budgeting category. I have tried some of the snippets floating around the forum to no avail. An example post is https://afterschoolfinance.com/save-money-tight-budget/
    2. I am trying to exclude a post (post 3595) from WP Show Posts. However, it still seems to be showing up.

    Thank you so much in advance for your help!

    Best,

    Connor

    #18750
    Tom
    Keymaster

    Hi there,

    1. You can try doing this in the shortcode: [wp_show_posts id="123" settings="taxonomy=category&tax_term=current"]

    You just need to change the 123 to the ID of your list.

    2. Just to confirm, you’ve added the post ID into the Exclude posts field, but that post is still displaying in the list?

    #18756
    Connor
    Participant

    Hi Tom,

    1. This shortcode works perfectly, thank you!

    2.Yes, Under WP Show Posts -> Selected List -> More Settings I have entered “3595” in the Exclude Post IDs field. For an example if where this shouldn’t be displaying, if you go to this post (https://afterschoolfinance.com/live-below-your-means/), the first post at the bottom where WP Show Posts displays is Christmas on a Budget. This is post 3595, which I have tried to exclude because it is seasonal.

    Thanks!

    #18766
    Tom
    Keymaster

    Strange, I wonder what the query is showing.

    Try this debugging code:

    add_filter( 'wp_show_posts_shortcode_args', function( $args ) {
        var_dump($args);
    
        return $args;
    } );

    What is the output above that list?

    #18775
    Connor
    Participant

    It’s showing the following

    array(8) { ["order"]=> string(4) "desc" ["orderby"]=> string(4) "date" ["post_type"]=> string(4) "post" ["posts_per_page"]=> int(3) ["ignore_sticky_posts"]=> bool(true) ["post_status"]=> array(1) { [0]=> string(7) "publish" } ["tax_query"]=> array(1) { [0]=> array(4) { ["taxonomy"]=> string(8) "category" ["field"]=> string(4) "slug" ["terms"]=> array(1) { [0]=> string(6) "saving" } ["operator"]=> string(2) "IN" } } ["post__not_in"]=> array(1) { [0]=> int(3401) } }

    #18780
    Tom
    Keymaster

    ["post__not_in"]=> array(1) { [0]=> int(3401) }

    This means that the ID you’re excluding is 3401. Perhaps it’s a different list?

    #18782
    Connor
    Participant

    Hey Tom,

    I have confirmed this is the list that is hooked in below the post content, so I don’t think that’s the issue. 3401 is the current post which it is excluding (per the checkbox in the “More” settings). However, it doesn’t seem to be excluding post-ID 3595 as well.

    #18784
    Tom
    Keymaster

    Ah, so you have it set to exclude the current post as well? What if you un-check that option?

    #18786
    Connor
    Participant

    Oddly, even when I uncheck that option, it is still excluding the current post and not the one I have specified.

    #18808
    Tom
    Keymaster

    Can you share the updated debug code that you shared above? Looking at the code, un-checking the “Exclude current” option should do the trick, but it would be helpful to see the var_dump info.

    #18827
    Connor
    Participant

    Hi Tom,

    Here’s what is showing with “Exclude current” unchecked and post 3595 listed to be excluded:

    array(8) { ["order"]=> string(4) "desc" ["orderby"]=> string(4) "date" ["post_type"]=> string(4) "post" ["posts_per_page"]=> int(3) ["ignore_sticky_posts"]=> bool(true) ["post_status"]=> array(1) { [0]=> string(7) "publish" } ["tax_query"]=> array(1) { [0]=> array(4) { ["taxonomy"]=> string(8) "category" ["field"]=> string(4) "slug" ["terms"]=> array(1) { [0]=> string(6) "saving" } ["operator"]=> string(2) "IN" } } ["post__not_in"]=> array(1) { [0]=> int(3401) } }

    #18842
    Tom
    Keymaster

    So what is 3401? Is that the current post that the list is on? Do you have any other custom functions added to the site?

    #18845
    Connor
    Participant

    Yes, 3401 is the current post. I do have a number of other custom functions added through Snippets, but none of them are related to WP Show Posts.

    #18873
    Tom
    Keymaster

    This looks like a bug on our end – the current post is excluded no matter what if it’s on a single post, which is overwriting your own exclusions. Will get a fix committed ASAP and will update you 🙂

    #18882
    Connor
    Participant

    Awesome, thanks Tom! I’m glad I’m not going crazy! Should it be possible to exclude both the current post and my own selected exclusions once this is fixed?

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