- This topic has 14 replies, 3 voices, and was last updated 3 years, 2 months ago by
David.
-
AuthorPosts
-
February 8, 2023 at 7:44 am #2525913
Jeffrey
Hey,
I want to add question and answer area on my Authors page. How can I achieve it?
You can take as an example this page – https://www.epicgardening.com/author/kelliklein/So, I want rich text area, which is bigger compared to a default Author bio area.
February 8, 2023 at 9:00 am #2526172David
StaffCustomer SupportHi there,
you would need to use a plugin like ACF to add a Rich Text field to the User Profile page.
Once thats in place we can assist with getting the user meta content and displaying it on your frontend.February 19, 2023 at 8:37 am #2538902Jeffrey
Hi David,
I have created Rich Snippet ACF in Author.
It’s represented in the Author edit page (admin panel).How can I represent it in Author archives?
February 19, 2023 at 9:35 am #2538966David
StaffCustomer SupportUse a PHP Snippet to create yourself a shortcode to get that rich text:
add_shortcode('author_qa', function(){ $author_id = get_the_author_meta('ID'); $author_qa = get_field('user_field_name', 'user_'. $author_id ); $html = '<div class="author-qa">' . $author_qa . '<div>'; return $html; });In the snippet, change:
user_field_nameto the name of your field.To display this, you can:
1. Create a new Block Element:
https://docs.generatepress.com/article/block-element-hook/
2. Set the Hook to where you want it displayed eg.
after_archive_description3. Add your
[author_qa]Shortcode to the editor.4. Set the Display Rules > Location to:
Author Archives5. Publish the element
February 19, 2023 at 10:17 am #2538999Jeffrey
Where/How should I do the first part? (PHP Snippet & shortcode creation)
February 19, 2023 at 5:18 pm #2539181Fernando Customer Support
Hi Jeffrey,
Here’s an article you may refer to regarding this: https://docs.generatepress.com/article/adding-php/#code-snippets
February 20, 2023 at 5:17 am #2539731Jeffrey
Update: It was HTML snippet, I changed it to PHP Snippet but nothing is shown.
Old:
When I tryadd_shortcode('author_faq', function(){ $author_id = get_the_author_meta('ID'); $author_qa = get_field('author_faq', 'user_'. $author_id ); $html = '<div class="author-faq">' . $author_faq . '<div>'; return $html; });It shows like this

What could be wrong?
February 20, 2023 at 5:51 am #2539778David
StaffCustomer Support1. This is the PHP Snippet:
add_shortcode('author_qa', function(){ $author_id = get_the_author_meta('ID'); $author_qa = get_field('user_field_name', 'user_'. $author_id ); $html = '<div class="author-qa">' . $author_qa . '<div>'; return $html; });You add this to whatever PHP Snippet plugin you’re using.
It will create a shortcode called:[author_qa]2. In your element, add the
[author_qa]shortcode.February 20, 2023 at 6:11 am #2539796Jeffrey
This is the code I create in Code Snippets plugin.
add_shortcode('author_qa', function(){ $author_id = get_the_author_meta('ID'); $author_qa = get_field('author_faq', 'user_'. $author_id ); $html = '<div class="author-qa">' . $author_qa . '<div>'; return $html; });Name of the new field is “author_faq”.
It creates shortcode [wpcode id=”80391″]
I insert this shortcode in Block elements, but it does not show up anything.
What additional information can I provide to troubleshoot?
February 20, 2023 at 9:42 am #2540156David
StaffCustomer SupportCan you share a link to where it should be displayed ?
February 20, 2023 at 9:44 am #2540159Jeffrey
Under the description (above list of articles)
February 20, 2023 at 10:30 am #2540233David
StaffCustomer SupportHold up….
It creates shortcode [wpcode id=”80391″]
I assume thats the plugin you’re using doing that ?
As the snippet i gave you IS creating the shortcode
[author_qa]So can you add
[author_qa]to your element ?February 20, 2023 at 11:20 am #2540299Jeffrey
I tried that as well.
You can check, it’s just text now.
February 20, 2023 at 11:23 am #2540301Jeffrey
Oh, I made insertion logic different in Code Snippet and it worked.
Thank you so much!
February 21, 2023 at 3:02 am #2540943David
StaffCustomer SupportGlad to hear that
-
AuthorPosts
- You must be logged in to reply to this topic.