Archived topic
Shortcodes not working on author archive
10 replies · Started by Adrian on May 27, 2021
Any idea why shortcodes don't display in the author archive?
It'd to display the shortcode as is.
The same shortcode displays fine in the author bio created using a dynamic GP block.
Example in private info.
Thank you.
Hi there,
how are you adding the Shortcode is it in the user biography field - as i believe that only outputs plain text by default.
Instead you could use the Block Element to insert that shortcode ( or create the entire entry header ) for your author archive.
Doing further research I found that WordPress strips the shortcodes on Archive pages.
I also found this on your forum that is about stripping them but what I want is for them to stop being stripped.
https://generatepress.com/forums/topic/remove-short-codes-from-the-posts-in-a-specific-category/
Please let me know if you can help me with the code.
Thanks.
Bumping it in case it was missed as you are often super fast.
Thanks.
Shortcodes will get stripped as will other HTML if you add it to the a USER meta field such as the Biography.
But they should work if you add them using a Block / Hook element to the archive - have you tried that method ?
I added code in functions.php so it doesn't strip HTML. It works fine on the posts see the author bio in private information.
add_filter( 'get_the_author_description', 'tu_author_desc_autop' );function tu_author_desc_autop( $output ) { return wpautop( $output );}
It's only stripped on the archive page.
Unless I am missing something the Block/Hook method won't work as it's not part of the page template but custom for each author and I have hundreds.
What exactly is the shortcode doing ?
Displaying this: https://gyazo.com/eb0aa8a7a9b9f0d3aab59ae31b2b5f4e
It's the author's books and no way to replicate that without leveraging a 3rd party plugin via shortcode.
Also, the entire author box line spacing and HTML formatting and links are kept in the archive page, just not the shortcode part.
Thanks.
Tom provides a snippet here that will parse a shorcode value from the author description, but i believe this will only apply if thats the only content of that field:
https://generatepress.com/forums/topic/author-description-add-shortcodes/#post-657073
David, your support is amazing :)
It worked - it displays everything correctly now, including the shortcode.
Thank you.
Glad we could be of help!