Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1417202

    natedawg
    Participant

    Hello,

    I’m having trouble moving ‘x_renew_entry_meta’ to the landmark_header. I’ve successfully created a large background featured image for single posts in the header, and I’d like the title to float over it (as shown in the screen grab). I placed the ‘x_renew_entry_meta’ underneath the title, but I can’t get the post author to show. Everything else (date/categories/comment count) shows, but the post author doesn’t.

    Here’s what I have now in the functions.php:

    if ( ! function_exists( ‘x_renew_entry_meta’ ) ) :
    function x_icon_entry_meta() {

    $author = sprintf(‘<span class=”show-date”>%2$s</span>’,
    get_author_posts_url( get_the_author_meta( ‘ID’ ) ),
    get_the_author()
    );

    $date = sprintf( ‘<span><time class=”entry-date” datetime=”%1$s”>%2$s</time></span>’,
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date( ‘m.d.Y’ ) )
    );

    $post_type = get_post_type();
    $post_type_post = $post_type == ‘post’;
    $post_type_portfolio = $post_type == ‘x-portfolio’;
    $no_post_meta = x_get_option( ‘x_blog_enable_post_meta’ ) == 0;
    $no_portfolio_meta = x_get_option( ‘x_portfolio_enable_post_meta’ ) == 0;

    if ( $post_type_post && $no_post_meta || $post_type_portfolio && $no_portfolio_meta ) {
    return;
    } else {
    printf( ‘<p class=”p-meta”>%s|%s</p>’,
    $author,
    $date
    );
    }

    }
    endif;

    Thanks!

    #1417331

    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! The code should have been this:

    if ( ! function_exists( 'x_renew_entry_meta' ) ) :
    function x_renew_entry_meta() {
    
    	$author = sprintf('<span class="show-date">%2$s</span>',
    	  get_author_posts_url( get_the_author_meta( 'ID' ) ),
    	  get_the_author()
    	);
    
    	$date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
    	  esc_attr( get_the_date( 'c' ) ),
    	  esc_html( get_the_date( 'm.d.Y' ) )
    	);
    
    	$post_type = get_post_type();
    	$post_type_post = $post_type == 'post';
    	$post_type_portfolio = $post_type == 'x-portfolio';
    	$no_post_meta = x_get_option( 'x_blog_enable_post_meta' ) == 0;
    	$no_portfolio_meta = x_get_option( 'x_portfolio_enable_post_meta' ) == 0;
    
    	if ( $post_type_post && $no_post_meta || $post_type_portfolio && $no_portfolio_meta ) {
    	 return;
    	} else {
    	  printf( '<p class="p-meta">%s|%s</p>',
    	    $author,
    	    $date
    	  );
    	}
    
    }
    endif;

    If this doesn’t work, would you mind providing us the url of your site with login credentials so we can take a closer look and fix the issue? This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    To do this, you can make a post with the following info:
    – Link to your site

    – WordPress Admin username / password
    – FTP Hostname
    – FTP Username
    – FTP Password

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thank you.

    #1417756

    natedawg
    Participant
    This reply has been marked as private.
    #1418343

    Rad
    Moderator

    Hi there,

    Please try this one

    if ( ! function_exists( 'x_renew_entry_meta' ) ) :
    function x_renew_entry_meta() {
    
    	$author = sprintf('<span class="show-author"><a href="%1$s">%2$s</a></span>',
    	  get_author_posts_url( get_the_author_meta( 'ID' ) ),
    	  get_the_author()
    	);
    
    	$date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
    	  esc_attr( get_the_date( 'c' ) ),
    	  esc_html( get_the_date( 'm.d.Y' ) )
    	);
    
    	$post_type = get_post_type();
    	$post_type_post = $post_type == 'post';
    	$post_type_portfolio = $post_type == 'x-portfolio';
    	$no_post_meta = x_get_option( 'x_blog_enable_post_meta' ) == 0;
    	$no_portfolio_meta = x_get_option( 'x_portfolio_enable_post_meta' ) == 0;
    
    	if ( $post_type_post && $no_post_meta || $post_type_portfolio && $no_portfolio_meta ) {
    	 return;
    	} else {
    	  printf( '<p class="p-meta">%1$s|%2$s</p>',
    	    $author,
    	    $date
    	  );
    	}
    
    }
    endif;

    Hope this helps.

    #1418364

    natedawg
    Participant

    Thanks. This doesn’t work, either. I’ve tried similar calls multiple times. It seems to have something to do with it being outside the actual entry.

    Is there a way to call the entry within this function so that

    'get_author_posts_url( get_the_author_meta( 'ID' ) ), get_the_author()

    retrieves the author successfully? I’m able to pull the author’s URL, but the name doesn’t show up.

    Thanks,
    Nate

    #1418729

    Paul R
    Moderator

    Hi Nate,

    Can you provide us your ftp login so we can properly edit the code.

    Thanks

    #1418992

    natedawg
    Participant

    I can’t provide an FTP login, but if you tell me which files to edit I can do it. Possible? Is there a way to call the current single post from the landmark_header?

    I know this is outside the scope of support, so I really appreciate the assistance!!

    Thanks

    #1419622

    Rad
    Moderator

    Hi there,

    Unfortunately, I’m not sure why it’s not working on your end either so can’t tell which files needs fixing, it’s best to check it directly. Post meta code are within the entry post since it’s within post loop or global post.

    Thanks!

    #1419642

    natedawg
    Participant

    Everything else – date, category, comments – are working. Does anything come to mind that could cause `get_author

    specifically not to work?

    Thanks!

    #1419959

    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! After several tries, it turns out that you will need this code:

    $author = sprintf( '<span>by %1$s %2$s</span>',
            esc_attr( get_the_author_meta( 'first_name', get_current_user_id() ) ),
            esc_attr( get_the_author_meta( 'last_name', get_current_user_id() ) )
        );
    

    If you need anything else, please let us know.

    #1420124

    natedawg
    Participant

    Awesome. Thanks! I should be able to tweak this to make the name link, etc.

    Thank you so much!!

    #1420150

    Thai
    Moderator

    You’re most welcome 🙂

    #1420161

    natedawg
    Participant

    One more question: I’m also trying to call the author avatar in this string, but I’m coming up with the generic avatar. Same issue I suppose. Here’s what I tried:

    $avatar = sprintf( '<span>by <a href="%1$s">%2$s</a></span>',
     get_author_posts_url( get_the_author_meta( 'ID' ) ),
     get_avatar( get_the_author_meta( 'ID' ), 32 )
     );

    The generic avatar is being added, so I know this is again an issue with calling the specific post author. I’ve been digging through the theme files trying to find the attributes, but I’m not having any luck. Could you you show me how to fix the above?

    #1420268

    natedawg
    Participant

    I figured it out! This is what worked for me, in case anyone else is curious:

    $avatar = sprintf( '<span>by <a href="%1$s">%2$s</a></span>',
    	get_author_posts_url( get_the_author_meta( 'ID', get_current_user_id() ) ),
    	get_avatar( get_the_author_meta('user_email', get_current_user_id() ), 32 )
        );
    #1420453

    Rue Nel
    Moderator

    Hello Again,

    We are just glad that you have figured it out a way to correct the said issue.
    Thanks for letting us know!

    Best Regards.