Forums

Howto create a link list of posts in specific category? (9 posts)

  1. hilj
    Member
    Posted 4 years ago #

    Hi everybody,

    I would like to create such navigation where I have listed all the posts as links from a specific category. I'd also liked to control amount of posts shown per category as well as the order.

    For example like this:
    PHOTOS 1 2 3 4 5 6 7 8 9
    THINGS 1 2 3 4 5 6 7 8 9...and so on...

    Every number would be a link to a one post in Photos/Things category.

    I searched and found this:

    <!--Show posts by category-->
    <?php if (in_category('4')) : ?>
    <?php $my_query = new WP_Query('cat=4&showposts=15'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    # "><?php the_title(); ?><br />
    
    <?php endwhile; ?>
    
    <?php endif; ?>
    <!--End Show posts by category-->

    I'm not quite following what's going on there... From what I know the in_category() should be inside a loop to work, if I put this in a loop , it multiplies all the posts (if I have three posts in a category, it shows all them three times). I'm a bit confused with this.

    Could some nice person break this down for me? I would appreciate that tremendously! Thanks.

  2. MichaelH
    Volunteer
    Posted 4 years ago #

    Take a look at this plugin, it does most of that for you:
    http://www.dagondesign.com/articles/sitemap-generator-plugin-for-wordpress/

  3. hilj
    Member
    Posted 4 years ago #

    Thank you! I'll give it a try :)

  4. hilj
    Member
    Posted 4 years ago #

    Hmm... I dont know if this is good for me after all.

    It shows the post name, for example like this:
    PHOTOS photos1 photos1 photos1 photos1

    I'd like a small image there or a bullet or some simple character or a number. I would need to edit the plugin.

    Can anyone still clarify the upper code? Thanks!

  5. CyberCoder
    Member
    Posted 4 years ago #

    hilj, look at the sidebar here and see if this is what you want.

    CyberCoder.net

    I put each post in one category ONLY, then list the Posts BY category, I think that is the same thing you want.

    Here is the code I use.

    <?php
     global $post;
     $myposts = get_posts('numberposts=7&category=8');
     foreach($myposts as $post) :
     ?>
        <li><a href=<?php the_permalink(); ?>><?php the_title(); ?></a></li>
     <?php endforeach; ?>
  6. hilj
    Member
    Posted 4 years ago #

    Thanks CyberCoder, never thought of that.

    I managed pretty easily to modify the plugin. Sorry for Dagon Design, I spoiled the plugin, hope it's okay :)

  7. leeroi
    Member
    Posted 4 years ago #

    hello hilj,

    could you post the modified version of the dragondesign plugin for download? i need the same thing as you do, i found it incredible that this plugin doens't exist yet. Displaying posts from a certain category in the sidebar is almost mandatory for anyone who uses WordPress as a content management system.

    hope to hear from you!
    gert.leroy [@] martialarts.be
    thanks !

  8. leeroi
    Member
    Posted 4 years ago #

    hilj, will this plugin put my posts in the sidebar?
    is it created for the sidebar?

  9. leeroi
    Member
    Posted 4 years ago #

    hilj, no need for that anymore,
    i found the perfect plugin for me here:
    http://wordpress.org/extend/plugins/category-posts/

Topic Closed

This topic has been closed to new replies.

About this Topic