Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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!!

    #469580

    Here 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.

    #470031

    Hi,

    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,
    Rikard

    #472621

    Hey Rikard,

    Sorry for my late reply.
    You will find the admin login in the private section.

    Thanks for having a look!

    #473243

    Hi!

    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 8 years, 9 months ago by Elliott.
    #474804

    Hey,

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Wrong author name on blog page?’ is closed to new replies.