Problem: I would like to display the Author User's custom field information in an Author archive, but the Types usermeta field shortcode does not seem to work.
Solution: You must include the Author's User ID in the user_id attribute in an Author archive. Unfortunately there is no built-in way to retrieve that Author's User ID simply. It requires a custom shortcode. Add the following code in your child theme's functions.php file, or to a new code snippet in Toolset > Settings > Custom Code:
function get_author_id_in_archive_func($atts) { return get_the_author_meta('ID'); } add_shortcode("get-author-id-in-archive", "get_author_id_in_archive_func");
This shortcode will return the User ID of the author in the current WordPress Archive.
Then go to Toolset > Settings > Front-end Content > Third party shortcode arguments and register get-author-id-in-archive. This will allow you to use the new custom shortcode as an argument in the Types usermeta field shortcode. Now your nested Types field shortcode syntax can use the user_id attribute like this:
[types usermeta='imya-na-russkom' user_id='[get-author-id-in-archive][/get-author-id-in-archive]'][/types]
Place this nested shortcode inside your WordPress Archive before the opening wpv-loop tag.
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/
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.
This topic is split from https://toolset.com/forums/forum/professional-support/
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 5 replies, has 2 voices.
Last updated by 4 years, 9 months ago.
Assisted by: Christian Cox.