How to make an author archive only for certain user role and show related CPT



I made a CPT where I’m taking the stakeholder’s ID as a custom field. All the stakeholders are actually a WordPress’ Registered User with a different role stakeholders – because at some point I need them to login to post their own content. So what actually I’m doing, I’m grabbing the userID and passing them as a custom field to that CPT.

Now I need to make a custom author archive, only specific to that role, where I can have all the posts of that CPT as per the custom field match.

What I did

I actually failed doing so. So I made a custom page template: where I queried all the users with the role stakeholders. They are visible now. But now I’m struggling showing the posts in which they are linked with their ID as a custom field.

Apart from this thought, I changed my route to another way, posting into that CPT using the certain user to activate their author archives. So, I tried, as an Admin, posting the post as a different user, but except the admin none other users are visible there in the dropdown menu. So I can’t choose other user for the post, while I’m logged in. 🙁
author dropdown menu

What can be

What I can imagine, or can do is: on my page template, on click pass the ID to the URL, grab it and show the posts specific to that ID on the same Page Template. But parameters like ?id=# is not SEO-friendly and I would need to rewrite URL – but I never tried that, so a bit afraid of it.


What’s the correct approach to doing such a trick?

, , Mayeenul Islam 4 years 2020-02-09T08:38:32-05:00 0 Answers 67 views 0

Leave an answer