Display Sibling Posts using WP Views

This is based on this tutorial:

http://wp-types.com/documentation/user-guides/displaying-brother-pages/

But I couldn’t get it working until by trial and error I found that the following worked:

  1. Create a View that pulls the child post using the filter
    Select related posts that are a child of the post set by the parent view.
    eg: “Further Works by Artist”
  2. Create a Content Template that uses this View eg: “Further Works” which uses the “Further Works by Artist” view to pull child posts of the parent view:
    [wpv-view name="Further Works by Artist"]
  3. Insert the “Further Works” Content Template in the Content template used to show a single child eg: Content Template “Work Details” shows the details of a child artwork and within it we insert the view “Further Works” to show other works by the same artist. The context of “Further Works” is set to be the parent of the current post by the id=”$artist” bit.
    [wpv-post-body id="$artist" view_template="Further Works"]

    where $artist is the slug of the post type of the parent.

  4. The result is that the page is a single child post (and artwork) that has within it a Content Template that has a context of the Parent post type. So, when the “Further Works by Artist” view pulls posts from the database it is pulling children of the Artist post type which are in fact siblings of the current single child post page.

3 Comments

  1. Richard Wells on October 29, 2014 at 2:16 am

    Thank you very much for this, it has helped me greatly. That tutorial you mention is very poorly written and has obviously confused a lot of people! One update I would make is that the wording in the View filter appears to have changed to “Select posts that are a children of the Post set by parent View. Post type [Child] is a child of [Parent] post type”. Also I believe View Templates are now called Content Templates.

    My problem now is that it does not seem to work with Ajax pagination… the first page renders fine, then it says “No items found”.

    • babbler on October 29, 2014 at 9:12 am

      Many thanks for pointing out the changes to the wording. I have updated the text as you suggest.
      As to the pagination issue, I did have a similar problem a while ago with pagination of a view and I narrowed it down to the security plugin I was using (iThemes Security) that was set to block long URLs.

    • babbler on October 29, 2014 at 9:23 am

      Strangely I just did a test View using the same filter and the wording was still:
      Select related posts that are a child of the post set by the parent view
      Are we running different versions of Views?
      I’m using 1.3.1.

Leave a Comment