-
locke85
Hi there,
I’d like to display the author image, name and website link in posts (CPT).
First I enabled the author support function for the CPT.
Then I added an headline block to the Elements Content Template, activated the dynamic text option, selected the author name. How do I identify the field name from the user/ author’s account that contains the URL of the website (see #1).
Finally I need to add the image of the author. How would you identify the name of the relevant field from the author’s account (see screenshot #2)?
Any advice is much appreciated.
Thanks,
Jan -
1. Try
author meta
>user_url
for website.2. Use a GB image block, set image source to author avatar.
-
locke85
Great, Ying. This works very well.
How would you solve #1 und #2 for the Author Archive? See link below in the private section.
Best,
Jan -
It should be the same. Does it not work?
-
locke85
Hi Ying,
sorry for not getting back earlier.
No, the image and “read more” Button (“mehr erfahren” in German) don’t work.
I sense the Dynamic content/ image blocks work differently on the autor page.
Any advise is much appreciated.
Best regards,
Jan -
It should work out of the box for the author archive.
If it’s not working, you need to debug, so disable all plugins except GP Premium, GB and GB PRO, if you are using any custom functions, disable them all.
Let me know 🙂
-
locke85
Hi Ying,
meanwhile I was able to rund a few tests regarding the author avatar image:
Single page (CPT + Content template)
A – GB Image block / Dynamic data / Data source (current post) / Image Source (Author avatar) –> Image appears
B – Dynamic Image block / Type (author avatar) –> Image appears for users with Gravatar and for users with Basic User Avatar based imagesAuthor archive page (Loop and Content template – both tested)
A – GB Image block –> n/a, Dynamic option option not available
B1 – Dynamic Image block / Type (author avatar) –> Image appears for users with Gravatar based images
B2 – Dynamic Image block / Type (author avatar) –> Image does not appears for users with Basic User Avatar based imagesAny thoughts as to why B / B1 / B2 are generating different results?
Best regards,
Jan -
Hi there,
the GP Dynamic Image block uses the core
get_avatar
function to return the avatar image. We don’t do anything special here , or add anything required for integration.If that plugin isn’t working then it has its own functions in place that deviate from how GP uses the core function to return that image.
You might want to try this plugin instead:
-
locke85
Hi David,
thanks for getting back. I followed your advise and activated the Simple Local Avatar plugin. Unfortunately, The result is still the same ;-(
I did some further testing and observed that not only the avatar image is missing, but also the author’s first and last name (both configured in the Loop template) . The breadcrumb and title should come in via Page Hero element. Those are missing also for archive page #2 (see links below).
Test results: the issue not related…
- to Roles / Privileges in WordPress: I assigned Super-User-Roles to Cindy (page #2) with no effect.
- to the Local Avatar plugin: Even w/o the plugin active the (Grav)Avatar from Tom is not showing (page #3)
- to the child theme: with the GP default theme active, the issue remains
- to the user login: page 1 is related to my own admin-user. But even in private mode without login the issue remains the same
Then I thought the only author archive page loading correctly is related to my own user which actually is the only one that created blog posts. So I temp. assigned a blog post to Cindy and voila the author pages loads correctly ;-).
Are you aware of any filter that would show related CPT posts even if the author is not linked to any blog post? We may be able to extend the existing function for activating the author support:
// CPT Hilfe Chat - Activate author support function add_author_support_to_posts() { add_post_type_support( 'wg_seo_chat', 'author' ); } add_action( 'init', 'add_author_support_to_posts' );
Any advise is much appreciated.
Best regards,
Jan -
You can use
pre_get_posts
to add CPT to author archives:function add_custom_post_type_to_author_archive( $query ) { // Check if we're on the author archive page and it's the main query if ( $query->is_author() && $query->is_main_query() ) { // Add your custom post type slug(s) to the query $query->set( 'post_type', array( 'post', 'wg_seo_chat' ) ); } } add_action( 'pre_get_posts', 'add_custom_post_type_to_author_archive' );
-
locke85
Wow, Ying. This works like a charm.
Many thanks.
An interesting observation regarding the YOAST breadcrumb block: It only shows if the user/ author has a regular blog post assigned.
Pls see page #2 from Cindy who does not have a blog post assigned and compare it to page #3 from Jan (with blog post assignment).
How would you explain/ fix that?
Thanks,
Jan -
The block is outputting the HTML, but no content, its most likely the way they fetch the object data, considering an empty author archive would also return a no results, theirs a high change it only displays author meta on a true has_posts condition.
you would need to speak to Yoast support about that.
-
locke85
Thanks for sharing your valuable view, David. Much appreciated.
I’ll reach out to the YOAST Support for further assistance.
One more thing: How do you identify user meta field names? Background: There are other fields like “Website” or “Expertise” which I’d like to pull into the author archive page also.
Thanks,
Jan -
The author meta uses the
get_the_author_meta
function.
Which lists the available meta fields in its codex:https://developer.wordpress.org/reference/functions/get_the_author_meta/
The
user_url
is the one for the web address.If fields are coming from other sources eg. a SEO plugin then you would need to check with the plugin developer on how to retrieve those.
-
locke85
Hi David,
I got you.
The rational behind:
- Search for “wordpress function user meta” in Google
- Retrieve the related function
- Look-up the related WordPress reference documentation
- Obtain a list of all fields available in the WordPress standard
If standard field are no good (for whatever reason) use custom field + custom function (get_*) to pull related data into a page.
It is always a pleasure working with professionals like yourself.
Thanks,
David -
You’re welcome – glad we can be of help!
- You must be logged in to reply to this topic.