• Hi,

    I am using UberMenu and they have been very helpful, but we have not been able to figure this out.

    They have a shortcode to display recent post in the menu with image and title.

    I want to add the author of the post under the title linked to the authors post.
    Here is the current code:

    $post_url = get_permalink($post->ID);
    		$author_name = get_the_author_meta('display_name', $post->post_author );
    $html.= '<li>'.	$image.
        				'<div class="wpmega-postlist-title">
        				<a href="'.$post_url.'">'.$post->post_title.'</a></br>
        				<a href="'.esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ).'">'.$author_name.'</a>
        				</div>';

    If you mouse over the sports menu tab and mouseover the author name while on the home page you will see it links correctly, but if you click into any other page if removes the author fro the URL.

    Site: http://mystreetlife.com/home

Viewing 1 replies (of 1 total)
  • Thread Starter iamthestreets

    (@iamthestreets)

    Got it working by adding this:
    $author_id = $post->post_author;

    And changing this to:
    <div class="wpmega-post-author"><a href="'.get_author_posts_url($author_id).'"><span>by '.$author_name.'</span></a></div>

    Note: putting code in backsticks is not working

Viewing 1 replies (of 1 total)
  • The topic ‘How do I link to authors post outside of loop’ is closed to new replies.