WordPress.org

Ready to get started?Download WordPress

Forums

Link to Posts by specific Author from menu (6 posts)

  1. tsdadam
    Member
    Posted 3 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

  3. tsdadam
    Member
    Posted 3 years ago #

    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?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    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.

  5. tsdadam
    Member
    Posted 3 years ago #

    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 http://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.

  6. esmi
    Forum Moderator
    Posted 3 years ago #

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

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

Topic Closed

This topic has been closed to new replies.

About this Topic