One Category on a page template (3 posts)

  1. mattatbase
    Posted 5 years ago #


    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,


  2. 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; ?>
  3. mattatbase
    Posted 5 years ago #

    songdogtech you absolute legend! thanks for your help buddy!


Topic Closed

This topic has been closed to new replies.

About this Topic