• Disgeae

    (@disgeae)


    I’m making a category page that only shows the posts in that category but everyone post is in a different DIV, is use category.php.
    The problem is that it shows all the post of all categories on a certain category page, this is the code:

    <?php $myposts = get_posts('numberposts=1000');
    foreach($myposts as $post) :?>
    <div class="post">
    <?php the_title(); ?>
    </div>
    <?php endforeach; ?>

    What am I doing wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Keyboard_Headaches

    (@keyboard_headaches)

    You Might try this, alot of people have gotten it to work but unfortunatly I can not, But it seems to be what you may be looking for.
    http://www.mihaivalentin.com/wordpress-tutorial-load-the-template-you-want-with-template_redirect/

    Thread Starter Disgeae

    (@disgeae)

    That’s not what I’m look for.
    I’m looking for the loop that only shows the post of that category that is chosen, nothing to do with template definitions.

    Chip Bennett

    (@chipbennett)

    I’m looking for the loop that only shows the post of that category that is chosen, nothing to do with template definitions.

    WordPress does this automatically. For example, for category foobar, the following URL will display all posts with the foobar category:

    www.example.com/category/foobar

    WordPress will use the category.php template file to render this page. If you want to override the display for only the foobar category, crate a template file named category-foobar.php. (More information: Template Hierarchy: Category Display)

    If that doesn’t suit your needs, please provide more detail regarding what exactly you’re trying to accomplish.

    Thread Starter Disgeae

    (@disgeae)

    Still isn’t what I need.
    For example I have posts in this categories:
    Postname – Category:
    Joe – WordPress
    Deer – Wordress
    Cat – PHP

    In the page http://www.example.com/category/WordPress I see the posts in that category: Joe and Deer.
    But what it now does; it shows Joe, Deer AND Cat.
    I just want to define that it only shows the posts of that category I’m looking in.

    Chip Bennett

    (@chipbennett)

    But what it now does; it shows Joe, Deer AND Cat.

    That’s because you’ve modified the default loop, somehow.

    Please post the loop code for category.php.

    If it is this:

    <?php $myposts = get_posts('numberposts=1000');
    foreach($myposts as $post) :?>
    <div class="post">
    <?php the_title(); ?>
    </div>
    <?php endforeach; ?>

    Please replace that with this:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <div class="post">
    <?php the_title(); ?>
    </div>
    
    <?php endwhile; endif; ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Only show the posts of that category’ is closed to new replies.