Skip Navigation

[Resolved] Creating related view– showing post as related to itself

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View that lists posts. I have two Query Filters applied to the View:
- Taxonomy filter, set by the current post
- Post ID filter, set to include only posts passed in to the View using a shortcode attribute "ids"
However, the current post always appears in the results. I would like to show only other posts in this View.

Solution:
Modify the post ID filter to exclude posts by ID, and pass the current post's ID into the View using the shortcode attribute "ids":

<div class="col-sm-8">[wpv-view name="related-posts-for-featured-view" ids="[wpv-post-id]"]</div>

Relevant Documentation: https://toolset.com/documentation/user-guides/passing-arguments-to-views/

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Kacey 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#584664
Screen Shot 2017-10-31 at 9.54.32 PM.png

I created a view to show related posts based on category. Occasionally it shows the post in its own related list. I thought I could filter it out with a Post ID filter, but it doesn't seem to be working. Screen shot attached of what I did that doesn't seem to be working. Refresh this page enough times and you'll see a post related to itself:
hidden link

#584871

Can you include the shortcodes you have used to place the View on this page? It looks like your post filter ID is set to include specific posts using a shortcode attribute. It seems like you would want to exclude specific posts, and pass in the current post's ID using ids="[wpv-post-id]", so that your filter would exclude the current post from the list of possible results. Otherwise, you'll need to provide a list of IDs you want to include, which kind of defeats the purpose of using related categories if I understand what's going on here.

#584873
Screen Shot 2017-11-01 at 9.56.35 AM.png

Good catch. I change it to exclude but it still is showing the posts as related to themselves. Screen shot of updated filter attached. The view is actually nested inside another view. This is how it's integrated into the loop template in the other view:

<div class="row featuredperson">
  <div class="col-sm-4"><a href="[wpv-post-url]">[wpv-post-featured-image size="custom" width="300" height="300" crop="true"]</a></div>
  <div class="col-sm-8"><h1>Featured: [wpv-post-link]</h1>
    <h4 class="introexcerpt">[types field='introduction' output='raw'][/types] <a href="[wpv-post-url]">Learn more →</a></h4>
  </div>
</div><div class="row featuredrelate">
	<div class="col-sm-4"><p>[wpv-post-title] is part of the following focus areas: [wpv-post-taxonomy type="category"]</p>
<p>Explore these related people, projects, and resources in the same fields:</p></div>
	<div class="col-sm-8">[wpv-view name="related-posts-for-featured-view"]</div>
</div>

And this is how that view is integrated into the page template:

[wpv-view name="featured-post-with-connections"]
#584946

Your query filter is set up to respond to a shortcode attribute "ids" but you haven't included that attribute in your View shortcode:

<div class="col-sm-8">[wpv-view name="related-posts-for-featured-view"]</div>

That attribute should be included, something like this:

<div class="col-sm-8">[wpv-view name="related-posts-for-featured-view" ids="[wpv-post-id]"]</div>

Give this a try and let me know the results.

#586890

Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.