Archived topic
How to add Q&A area on Author page
14 replies · Started by Jeffrey on February 8, 2023
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.
Hi 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.
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?
Use 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_name to 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_description
3. Add your [author_qa] Shortcode to the editor.
4. Set the Display Rules > Location to: Author Archives
5. Publish the element
Where/How should I do the first part? (PHP Snippet & shortcode creation)
Hi Jeffrey,
Here's an article you may refer to regarding this: https://docs.generatepress.com/article/adding-php/#code-snippets
Update: It was HTML snippet, I changed it to PHP Snippet but nothing is shown.
Old:
When I try
add_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?
1. 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.
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?
Can you share a link to where it should be displayed ?
Under the description (above list of articles)
Hold 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 ?
I tried that as well.
You can check, it's just text now.
Oh, I made insertion logic different in Code Snippet and it worked.
Thank you so much!
Glad to hear that