Skip Navigation

[Resolved] Display Posts related to author

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

Problem:
How can I display Posts where the currently logged in user is the author?
Later I want to display related posts to those posts.

Solution:
You can create a View with an author query (same as the logged in user) and then add another view, which queries the relationship of which you want to display related posts.
The view should display the one end of that relationship and have a Query filter to show posts related to the post in the loop.
Then, the first view can be inserted anywhere to display posts of the current user and its related posts of another type.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/

This support ticket is created 5 years, 7 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Author
Posts
#1269001

Tell us what you are trying to do?
I have made created a many-to-many relationship between posts and Instructor-Profiles. I have also added Instructor Profiles posts and made the author of the post to a user. How can I display all the posts which are allocated to the user using this many-to-many function? I have tried the following.
hidden link
Here I am adding this view to -my-accounts page. But I am unable to make it work.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#1269077

We have a great tutorial that explains the exact steps to your goal from scratch: https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

It explains how to create the relationship between the user and post-type mimicking the user, and how to display connected data.
Generally, it's done by displaying a List of User Posts filtered by author equal to (for example current user), and in that View's Loop, you display related post-Data, using another View which lists the related posts.
It is important that this second View should have a Query filter to filter posts related to the one in the parent view loop.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-related-child-posts/, https://toolset.com/documentation/user-guides/filtering-views-query-by-author/

Then you can insert the first View with the User Posts to a page and it'll list each related post to the User Post, and since that is filtered by the author it'll show the posts related to that user.

Please let me know if you need further help with this.

#1269171

I have a user 'abcd', for which I have created a post 'abcd' under custom post type named 'instructor-profile', I have created a many-many relationship between 'instructor-profiles' and posts.

Expected Result: When 'abcd' logs in and goes to the homepage of the website, he sees the posts assigned to him/her under 'Instructor_Profiles Posts' as shown in this screenshot. See here: hidden link

My activity summary to achieve the same is mentioned below:

My Loops View: hidden link
My Query Filter: hidden link
View inside the loop view: hidden link

Actual Result: It always shows 'no items found' on the homepage.

Help me achieve the Expected Result. I am unable to do so on my own. Appreciate all your help. TIA.

#1269231

The replies here in the forum are public, if you submit access details please ask the Support Personnel to activate a private reply. I removed the previously submitted details, therefore.

Related to the display of the related posts, you are on the right path, I just see a few issues to correct:

1. The Code you use has corrupt apostrophes (” instead of ")
2. I think the best for me would be to log in and create a View for you to see, which lists all related posts of the current user logged in.

But I miss the Website on which you develop this since the only website registered in your name is hidden link, but there I cannot log in with the provided data.

Can you confirm in the next private reply the website and access data?
Note that Toolset Presentation only gives access to one website, hence the Support Request here should be handled for hidden link - maybe the password I have is wrong and I tried on the right site?

Once I logged in I can set up an example of this

#1269307

Hey Beda,

The current issue is not on my learning.krenovate.com website. It's on one of the discover-wp websites. hidden link

#1269737

Please, can you give me access to that site, in this case?
I cannot set up an example without accessing it.
It would be better setting up examples on your existing data so the examples are realistic, otherwise, I could set up my own instance on https://discover-wp.com/, but that would be an empty example or a copy of an existing training site.

I've enabled the private form again.

#1270485

Hey Beda,

It's been long. Looking forward to a reply from your side.

#1271255

Hey Beda,

I would really appreciate quick help from your side, we urgently require this funcitonality to make our website live.

Regards,

#1271535

I'm on weekends Sunday and Monday, you can see my working hours here:
https://toolset.com/forums/users/beda-s/

I could organize your thread to be assigned to any supporter closer to your timezone (please mention any preferences).
Please let me know if that would help.

Related to the thread's topic, I've set up 2 Views, which shows all Posts which are related to the correct Instructor Profile (so when any user logs in, they will see the posts ligated to their Instructor Profile).
The Views are here: hidden link. hidden link

The first View queries all posts related to the post in the loop (parent view), and the second view queries all posts that are written by the currently logged in user.
When you place the parent view (hidden link) into a page, you will see a list of posts ligated to that instructor profile.

Please let me know if something remains unclear!
Also if you need someone closer to your timezone please feel free to request this so I can adequately re-route your request 🙂

#1271595

Hey Beda,

Thanks for letting us know your schedule. We appreciate your proactive support as well. We can definitely wait for your response. You don't need to assign this ticket to someone else.

Just to keep you posted on the issue:

I have activated both the views for users on the homepage. You can see them here: hidden link
But Whenever I log in with my user "abcd" or "cdef" I am unable to see the posts ligated to their Instructor Profile. hidden link

Please help. Will wait for your response. Sorry to bother you on your weekends.

Thanks
Puneet

#1271605

I created a Dummy Profile for me:
hidden link

Indeed on hidden link there was no post, that's because I made a tiny mistake in hidden link. Instead of Posts, I asked for Instructor Profiles in the Query filter here - I adjusted that, now you can see the front end displaying the current users' Instructor Profile, and below a list of posts connected to that profile.

#1271659

My issue is resolved now. Thank you!