WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] List ALL POSTS by Author (16 posts)

  1. katie1
    Member
    Posted 8 years ago #

    Is there a particular code or please, direct me to the codex files where the tag is explained, where I can insert something (code or whatever) into my sidebar (outside the loop?) that will generate a list of links that displays the title only of all posts by a specific author?

    I know I've read somewhere that the general view on this is a no-go, because some posts are numbered in the 100's, but I require this for book listings.

    Help would be appreciated.

    PS: I've read the codex extensively, and plugins page but I can't seem to find this exact pull code.

    Thanks

  2. Joshua Sigar
    Member
    Posted 8 years ago #

    You'd just need a Loop that will retrieve and display Posts of certain author. The first link shows you how to retrieve based on certain criteria. The second link shows you how to set up another Loop

    http://codex.wordpress.org/Template_Tags/query_posts
    http://codex.wordpress.org/The_Loop#Multiple_Loops

  3. whooami
    Member
    Posted 8 years ago #

    this is what you are looking for :

    <?php the_author_posts_link(); ?>

    on second read, thats not going to do what you want (just display titles) but i thought I would leave it up just in case someone else wanders in and reads 1/2 post thinking that youre looking for something that they are too.

  4. katie1
    Member
    Posted 8 years ago #

    Thanks alphaoide & whooami - I'll try the articles and post back my findings.

    whooami - thanks for the code but you're right its not what I'm after exactly.

    I'm using the code ?php the_author_posts_link(); ?> for a passable URL link to my author.php. But thanks anyway. :)

  5. katie1
    Member
    Posted 8 years ago #

    ok. I've checked these articles out - (quick note: I've already studied them extensively and I don't think they're exactly what I'm after) and I'm a little confused.

    here is the code after reading the article:

    <?php query_posts('cat=22&author=id&order=ASC&posts_per_page=-1'); ?>

    Now my question:

    If I use this code in my sidebar
    a)will it generate a list of links that displays ALL POSTS TITLES based on current author being queried?

    b) I don't think I've set the author "query" right, so that its dynamic eg: whatever author is queried will display a list of post TITLES as links in the sidebar.

    Dammit. I still need help. Currently reading external articles on this subject.

  6. Joshua Sigar
    Member
    Posted 8 years ago #

    a) You will need a Loop to display the query result. Consult the second link I posted.
    b) Worry about it later; hardcode the id for now.

  7. katie1
    Member
    Posted 8 years ago #

    Thanks alphaoide, but I have a question I can't seem to get my head around.

    after reading the multiple loop article, its saying that I need to insert the query loop before "regular" loop expressions. I understand this and I'm pretty comfortable with trying it

    However, I just need someone to clarify if I do that, insert this query loop code BEFORE "regular" loop expressions, can I then insert the above code into my sidebar and it will generate the list of POST TITLE links as I require or will it generate a list of links in my main web page instead?

    Gosh, I hope you understand my qestion. :)

  8. Joshua Sigar
    Member
    Posted 8 years ago #

    Leave the existing Loop alone.

    Go to sidebar portion (which should be after and outside the existing Loop) and add something like the following.
    // query_posts(author=1...
    // the Loop that output post title link

  9. Kafkaesqui

    Posted 8 years ago #

    query_posts() is used to initialize a post loop, hence you still need the loop (any loop) to display what you're after. In this case, you'd want something like the following:

    <?php query_posts('cat=22&author=id&order=ASC&showposts=-1'); ?>
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php endwhile; endif; ?>

  10. katie1
    Member
    Posted 8 years ago #

    Ok. I tried Kafkaesqui's suggestion, and put the above coding into my main single.php template (inclusive of loop expressions as shown) and then I inserted <?php query_posts('cat=22&author=id&order=ASC&showposts=-1'); ?> into my sidebar and my page went bonkers.

    Guess that isn't right, huh?

    I also tried alphaoide's suggestion and left the loop alone (ie: regular loop expression only) and inserted into my sidebar <?php query_posts('author=6'); ?> to no effect - I got blank section where it was supposed to be generated.

    I also tried a numer of variations, using both alphaoide & Kafkaesqui's suggestions and I got my very own 404 page.

    I never realised that it was so hard to generate a list of links that outputs post titles from an ANY author if I clicked my way through to author.php or single.php where that author was showcased.

    Surely there has to be a way to generate a list of links based on whatever author one wants to view?

    PS: Also tried coffeecup's plugin, but it didn't generate a list of POST TITLES links based on dynamically generated author viewing...

    Does any one have any more suggestions? I'm still game to try anything at this point in time... :)

  11. katie1
    Member
    Posted 8 years ago #

    Update:

    I threw the entire:

      <?php query_posts('cat=22&author=id&order=ASC&showposts=-1'); ?>
      <?php if(have_posts()) : while(have_posts()) : the_post(); ?>

      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

    <?php endwhile; endif; ?>

    into my sidebar and that didn't work, either...

  12. Kafkaesqui

    Posted 8 years ago #

    Can you qualify what "bonkers" means here? Doesn't really explain the problem or error you see. It's also unclear in your description how you're setting things up. Why are you editing single.php? Is this where the sidebar code is located? Keep in mind when I describe initializing a post loop with query_posts(), I mean you're creating a new one independent of the primary loop (i.e. The Loop) found in your templates.

    Finally, you do have an author with the user ID of 6, and this author has posts, correct?

    EDIT: Are you altering author=id to the correct ID # in the code you list above? In other words, id should be replaced with the user ID of the author.

  13. katie1
    Member
    Posted 8 years ago #

    Ok. Bonkers was a little harsh, but frustration is getting to me. Bonkers in this case is a simple 404 custom error page... forgive the use of colourful adjectives, please.

    I want to generate a comprehensive list of post titles links that comes from the currently viewed author which is outputted on my single23.php template.

    This template is deep rooted ie:

    books
    romance
    regency
    single product page (single23.php)

    This templates outputs thumbnail book image and all information relevant to this book title. I want all post titles by this author to be displayed in the single23.php's sidebar as links only, so that anyone viewing the page can click "other titles" by this author, which then takes them to the author.php for all "posts" by this author.

    Does this make sense?

    To make life easier, I've made each book title its very own post, hoping to get around this problem. Everything works brilliantly, except for this.

    I understand that I was supposed to generate a new loop, independent of the existing loop structure. I did try what you suggested by placing your information above the existing Loop expression but all I got was a custom 404 error - no posts exists.

    My author id is correct - author 6 has the "posts" under which I want to trial this method.

    Obviously I want to use whatever method will bring up a list of Post Titles for the author which is currently being viewed, which means hard coding speciic author id's into the sidebar will be a nightmare and probably defeat the purpose of dynamically generated links.

    I'm using the category structure as a bookstore, so you can image what my final numbers of "posts" will be for each and every book...

    Whew. I hope this makes a little more sense.

    Kate

  14. katie1
    Member
    Posted 8 years ago #

    Ok. Another update:

    after much checking and re-checking, and basically playing around hoping (and praying) that I won't blow up my site, I've finally got this to work.

    ie: generates a comprehensive list of all author posts as links in the sidebar.

    <p class="subheading">other titles by:
    <?php the_author(); ?>

      <?php query_posts('cat=22&author=6&order=ASC&showposts=-1'); ?></code>
      <code>
      <?php if(have_posts()) : while(have_posts()) : the_post(); ?></code>
      <li>
      [a href]="<code>
      <?php the_permalink(); ?>"><?php the_title(); ?></code>[/a]
      </li>
      <code>
      <?php endwhile; endif; ?>`

    Thanks Kafkaesqui and alphaoide for your input and patience.

    Now, can someone please tell me how I can use the above code to bring the list of links up regardless of which author is currently being viewed?

    At present the above code only works if author=id is given a number (ie:6).

  15. Joshua Sigar
    Member
    Posted 8 years ago #

    query_posts('cat=22&author=' . $post->post_author . '&order=ASC&showposts=-1');

  16. katie1
    Member
    Posted 8 years ago #

    Thanks alphaoide - that worked like a charm.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags