Forums

show only posts of category x on page (4 posts)

  1. yannickdepauw
    Member
    Posted 2 years ago #

    Hi,

    not too good with php, ran into a problem.
    Ive succesfully created a template for "page x", to only show posts with category "x" onto that page,
    now I want to have "page y" to only show posts from "category y".
    I thought using the same Loop and only changing the category name would help, but it doesnt.

    What am I missing?
    posts with category "events" dont show; using this code.

    <div class="page-content">
    <?php query_posts('category_name=events&showposts=15');
    	if(have_posts()) :
    	while(have_posts()) : the_post();
    ?>
    <?php the_content(); ?>
    <div class=post-intro>
    <?php edit_post_link(Edit); ?>
    </div>
    
    <?php endwhile; ?>
    <?php else : ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2>(Not Found)</h2>
    </div>
    <?php endif; ?>
  2. thescribbler
    Member
    Posted 2 years ago #

    When you say it doesn't work, what exactly is happening?

  3. MAzCastro
    Member
    Posted 2 years ago #

    ?

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    Try using the category ID from the events category 'cat=x' instead of the category_name argument.

    Also see Page of Posts example in the {{Pages|Pages article]].

    Also consider this technique if the goal is just to be able to access category archives while using a Page based navigation:
    How to easily display links to both Pages and Categories in the blog navigation header?

Topic Closed

This topic has been closed to new replies.

About this Topic