Skip Navigation

[Resolved] Add atuhor box to post

This support ticket is created 5 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by hugoC-5 5 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1217474

I created a view containing some custom user fields. I would like to add this as an author box to my post content template for specific categories. So if the post belongs to categories x, y or z the author box should be displayed.

I got this basically working but I still have a few questions:
- How can I display this view only on posts in specific categories?
- How can I filter the view so it displays the post author? At this point I get the complete list of authors instead of just the author of the specific post.

Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/creating-custom-user-profiles/

#1217694

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-03-20 at 10.06.32.png
Screenshot 2019-03-20 at 10.02.30.png

You can use conditional shortcodes to wrap where you insert the View so that it only applies when the current post belongs to certain categories.

There is fairly lengthy documentation at: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

You might find the UI intuitive enough if you try it.

In your template highlight the wpv-view shortcode then press the conditional output button.

It should be clear enough how to test for the categories in question, which will insert a wpv-conditional shortcode around your wpv-view shortcode.

Your View lists users and you want to limit it to the user who is the author of the current post.

For that insert a Query Filter for a specific user where the user is specified by a shortcode attribute (which, as you can see in the screenshot defaults to 'users').

So we are going to pass the ID of the user as an attribute in our wpv-view shortcode that inserts the View.

We can generate the ID of the author of the current post using the wpv-post-author shortcode. Insert using the Fields and Views button so that it outputs the needed attributes (see screenshot).

Your final wpv-view shortcode will look something like this:

[wpv-view name="my user view" users="[wpv-post-author format='meta' meta='ID']"]

(Note that I had to edit the wpv-post-author attributes to use single quotes.)

#1217861

My issue is resolved now. Thanks a lot!