WordPress.org

Ready to get started?Download WordPress

Forums

Want to list all posts from 1 category in sidebar (11 posts)

  1. wearemoviegeeksdotcom
    Member
    Posted 6 years ago #

    I have a couple of plugins that show the most commented posts, and recent posts, but I would like to have one that will list all posts from one category. is there a plugin or code snippet that will achieve this? I searched around but didnt find anything that would do this.

  2. hakre
    Member
    Posted 6 years ago #

    Please search the codex, normally is is supported within themes by a simple wordpress function call. When I remember correctly it is called wp_list_pages.

  3. wearemoviegeeksdotcom
    Member
    Posted 6 years ago #

    that will work if i want to list posts in all the categories, but there is no parameter to select 1 category and list each post under that.

  4. wearemoviegeeksdotcom
    Member
    Posted 6 years ago #

    nevermind..found it.

    thanks

  5. wearemoviegeeksdotcom
    Member
    Posted 6 years ago #

    ok, i though that using the wp_list_categories with an include tag would do it for me, but it wont list each post under the category, just the category name.

  6. hakre
    Member
    Posted 6 years ago #

    well but it should be possible to use get_posts limited to one category:
    http://codex.wordpress.org/Template_Tags/get_posts#Posts_list_with_offset

  7. TrishaM
    Member
    Posted 6 years ago #

    get_posts will show the posts, not list them. I think what you want is wp_list_categories - see this Codex doc for more info on how to use it:

    http://codex.wordpress.org/Template_Tags/wp_list_categories

    I use it in my sidebar and it works, however, with 2.5 it now inserts the word "category" before the actual category name, which I don't want. I'm searching now for a fix for that (my category list appears like this:

    sitename/category/products/widgets/

    what I want is:

    sitename/products/widgets/

    If you find a fix for this please post it!

  8. hakre
    Member
    Posted 6 years ago #

    get_posts will show the posts, not list them.

    Well, that is not true. It will actually query the posts. You can do whatever you want with that query then, for example creating a list of posts:

    <ul>
     <?php
     global $post;
     $myposts = get_posts('numberposts=5&offset=1&category=1');
     foreach($myposts as $post) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     </ul>

    This is the code example from the codex I linked in my post above. As you can see, it is creating a list of posts. In this Example the first 5 posts of category with the ID 1 are listed.

    Your suggestion of wp_list_categories is misleading. It is for displaying a list of categories, not of posts.

  9. TrishaM
    Member
    Posted 6 years ago #

    You're right - I am using it to display Child categories of specific Categories, thusly:

    Parent Category
    Child Category 1
    Child Category 2

    and so forth..........my bad. I think I misread the original question.

  10. hakre
    Member
    Posted 6 years ago #

    wearemoviegeeksdotcom, did my suggestion helped you?

  11. heriz
    Member
    Posted 5 years ago #

    I don't know whether it helped him but it certainly helped me. Thank you!

    Do you (or anyone else) happen to know if it's possible to dynamically highlight the given title of the post you're on in that sidebar list?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.