I am trying to show sibling posts of the single content template I am viewing. My relationships are staff members, departments.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-related-child-posts/
I am following along here. My syntax is:
[wpv-post-body item="@staff-member-department.parent" view_template="department-content-template-parent"]
Last time, you told me that the shortcode is malformed. I can confirm that is likely because when I remove the relationship the template runs. I have other plain html that tells me whether it gets to the parent template.
--Sam
Hi, I'll be glad to take a look. I need some more information.
- What is the relationship slug of this relationship? You can find this by going to Toolset > Relationships and editing this relationship.
- Which post type is the parent and which post type is the child in the relationship?
- Can you share the contents of the department-content-template-parent Content Template?
- Where have you placed the shortcode you shared in this ticket?
- Have you created a View of the child Departments yet? If so, where have you placed this View?
Hi, I'll be glad to take a look. I need some more information.
- What is the relationship slug of this relationship? You can find this by going to Toolset > Relationships and editing this relationship.
staff-member-department
- Which post type is the parent and which post type is the child in the relationship?
Staff member is child. Department is Parent.
- Can you share the contents of the department-content-template-parent Content Template?
[wpv-view name="staff-members-related-to-department" item="item="@staff-member-department.parent"] (the html doesn't output, but the child's does.) I have noticed the misspelling and corrected it to item=. I'll test it again, but wanted to reply to you while I do so.
- Where have you placed the shortcode you shared in this ticket?
In the child's content template. to be clear, that is of staff members.
- Have you created a View of the child Departments yet? If so, where have you placed this View?
It's of child staff members, not of departments. I've placed it in the Parent Department content template. I want it to show up on the other staff member (single) pages.
[wpv-view name="staff-members-related-to-department" item="item="@staff-member-department.parent"]
The Staff Members View shortcode should not use an item attribute. The filter for the Staff Members View is based on the current post in the Loop, so the Parent Department Content Template will provide the context needed to show the sibling posts.
The item attribute should be applied to the Content Template used to display the parent Department:
[wpv-post-body item="@staff-member-department.parent" view_template="department-content-template-parent"]
No luck.
Here is my code:
View code:
Select posts in a Staff members Departments relationship that are a related to the current post in the loop.
[wpv-post-link]
[types field='photostaff' title='%%TITLE%%' alt='%%ALT%%' size='thumbnail' class ="image-rounding" ][/types]
Department content template: (inserted via your shortcode into another content template)
department-content-template-parent (slug)
[wpv-view name="staff-members-related-to-department"]
I think it will be best if I can log in and see how you have things set up. If that's okay with you, please provide login credentials in the private reply fields here.
I'm trying to look at a Department post on the front-end of the site, but I see an error. Can you resolve the error message here so I can continue? hidden link
Parse error: syntax error, unexpected '') ) { ' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')' in /path/to/files/genesis-extender/plugin/custom-widget-areas.php on line 67
Yes, sorry I was in there at the same time as you so there were locks. I'm going to try to see what the cause is. Hang on.
I am happy to say I resolved the error.
Turning on e-mail notifications
hidden link
I edited this View and changed the "Order by" option. It was previously set to "Field - Last name". If you look in the options for this field you can see that there are two fields with the name "Field - Last name", so I think the wrong one was selected. A quirk of WordPress searches is that if you sort or filter by a field, posts with no value for that field will not appear in the results. So you've probably got another custom field in a different custom field group, and your original filter was pointing at that other field.
Seems to be working now, can you check and let me know?
Actually, I seem to have many duplicate entries for sort by, owing likely to slugs that weren't released. Any suggestions for how to fix this related issue?
I'll do some more testing and see if I can get content templates to work now.
Thank you for your patience. Almost, but not quite! I can't call that view from the staff members single prototype page located here:
hidden link
--Sam
Can you provide some additional detail about what are you trying to accomplish by placing this View on the Staff Member single post? Since the current Staff Member's siblings are different in different Departments, I'm not sure what you want to show.
Here is an example showing 3 Departments and their Staff Members (SM):
Dept 1
- SM 1
- SM 2
- SM 3
Dept 2
- SM 1
- SM 4
Dept 3
- SM 2
- SM 3
- SM 4
Now let's say I visit the single post for Staff Member 4. What siblings should appear?