Tagged: author name, Blog, blog page
-
AuthorPosts
-
July 7, 2015 at 11:52 am #469563
Hey there, I thought this could be a common bug, but I didn’t find anything. I have a page “news” where I use the blog shortcode to display all blog posts. But instead of the name of the author my name (Eva Nitsche) is always displayed. No matter who posted the entry. The permalink to the authors page is correct.
Please have a look here: http://dgkv.info/news/
There are just three entries right now, but I have tested with other users and other roles. Everytime my name is displayed.
I use a child theme. Please have a look at this issue.
Thank you!!
July 7, 2015 at 12:28 pm #469580Here is the code I use (includes > loop-index.php):
$author_id = get_query_var( 'author' ); if(empty($author_id)) $author_id = get_the_author_meta('ID'); $vorname = get_user_meta( $author_id, 'first_name', true); $nachname = get_user_meta( $author_id, 'last_name', true); $heading = $vorname." ".$nachname;
And the output in the <header>:
echo '<span class="blog-author minor-meta">'.__('by','avia_framework')." "; echo '<span class="entry-author-link" '.avia_markup_helper(array('context' => 'author_name','echo'=>false)).'>'; // DGKV: Hier wird der Name und der Link zum Autor ausgegeben echo '<span class="vcard author"><span class="fn"><a href="'.get_author_posts_url(get_the_author_meta( 'ID' )).'">'; echo $heading; echo '</a></span></span>'; echo '</span>'; echo '</span>';
What is wrong there?
The problem only occurs on the blog page created with the shortcode. If you have a look in a category or at the single blog post all is fine there.
July 8, 2015 at 7:28 am #470031Hi,
Could you please provide us with a temporary admin login so that we can take a closer look? You can post the details in the Private Content section of your reply.
Regards,
RikardJuly 13, 2015 at 7:17 pm #472621Hey Rikard,
Sorry for my late reply.
You will find the admin login in the private section.Thanks for having a look!
July 14, 2015 at 3:38 pm #473243Hi!
Why are you editing the loop-index.php file? It looks like your just doing the same thing but in a different way. What exactly are you trying to change there?
Anyways I think the problem is on this line.
$author_id = get_query_var( 'author' );
That’s not going to grab the ID from the loop. Try this out.
$author_id = $the_id;
Regards,
Elliott- This reply was modified 9 years, 4 months ago by Elliott.
July 17, 2015 at 11:24 am #474804Hey,
Thank you for your reply. I realized that the code has to be moved inside the loop.
Now I did it like that, and it works perfectly:echo '<span class="vcard author"><span class="fn"><a href="'.get_author_posts_url(get_the_author_meta( 'ID' )).'">'; $author_id = get_the_author_meta( 'ID' ); $vorname = get_user_meta( $author_id, 'first_name', true); $nachname = get_user_meta( $author_id, 'last_name', true); $heading = $vorname." ".$nachname; echo $heading; echo '</a></span></span>';
Eva
-
AuthorPosts
- The topic ‘Wrong author name on blog page?’ is closed to new replies.