• I’ve been reading the author_page help in the codex but can’t seem to find what I want.

    I want to be able to add a menu item that links to posts by a specific author, and I can’t seem to figure it out. I know there’s code to get a list of authors, and then from there to link to their posts, but I want it more specific.

    For example, if I have an author named Bob, I want a menu entry labeled ‘Bob’ with a link to a page of his posts. I’m guessing I need to pass his user ID to that page for it to happen, and I’m fine with finding the users’ IDs, but creating a page of posts from that ID is where I fall over.

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter tsdadam

    (@tsdadam)

    That’s the page I’ve read, as far as I can see in there there’s no way to link to a specific user’s posts page from a menu entry, only from either clicking on their name on a post, or from creating a list of authors and linking from there.

    Unless I’m missing something?

    To create a menu link, I think you’d need to set up a custom menu and then use the Custom option to add your specific author links.

    Thread Starter tsdadam

    (@tsdadam)

    I really need to know:

    a) the code to put in The Loop on the author’s page, like this;

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <li>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
                <?php the_title(); ?></a>,
                <?php the_time('d M Y'); ?> in <?php the_category('&');?>
            </li>
    
        <?php endwhile; else: ?>
            <p><?php _e('No posts by this author.'); ?></p>
    
        <?php endif; ?>

    and b) what to put as the url for the menu entry, like https://www.myurl.com/authors/userid=3 or whatever?

    I’m not sure if I’m putting across what I’m trying to do well enough.

    a) Have another look at the author templates page I linked to above. There’s sample code on there.

    b) https://www.myurl.com/?author=3

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Link to Posts by specific Author from menu’ is closed to new replies.