Support » Themes and Templates » One Category on a page template

  • Hi,

    I’m sorry if this question has been asked before, but i cant seem to find the answer i require with googling or by trailing this forum.

    I have a live site which is constructed main using ‘pages’. Posts are used for updates and posted in two categories, ‘general’ and ‘news’. I used the hyrbid theme to create my templates and used the blog.php template to bring all posts to the page called ‘Blog’. I now require however two separate pages, one for the category ‘general’ and one for the category ‘news’. These must remain as ‘Pages’ calling on a template to allow other functionality to continue working, hense i cant just link to ‘/category/news’ 🙁

    Can anyone help me out with the snippet required to filter the query?

    Many many thanks in advance,


Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Mark Ratledge


    Forum Moderator

    You can try this query to place the latest post from “mycategory” into a page template; you can use this in the post/page editor if you enable php execution.

    <?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
    <?php the_title(); ?></a><br /><?php the_content(); ?><?php endwhile; ?>

    songdogtech you absolute legend! thanks for your help buddy!


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘One Category on a page template’ is closed to new replies.