WordPress.org

Ready to get started?Download WordPress

Forums

query posts to static front want to add category parameter (4 posts)

  1. dragonsjaw
    Member
    Posted 2 years ago #

    I am using

    <div id="frontpagepostpull">
    <?php $temp_query = $wp_query; ?>
    <?php query_posts('showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    	<div class="post" id="post-<?php the_ID(); ?>">
    	<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h4>
    <?php the_post_thumbnail('front-page-post-thumbnail'); ?>  <?php the_excerpt(); ?>
    	</div>

    To pull the first post to the static front page.
    What I really need for this is the first post in any of 3 different categories.
    How would I write that in?

    thanks

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'category_name' => 'staff, news, other',
    	'posts_per_page' => 1,
    	'paged' => $paged
    );
    query_posts($args);
    ?>
  3. dragonsjaw
    Member
    Posted 2 years ago #

    Thanks Esmi,
    But that (with the proper category names) did not pull anything to the static front page.
    What am I missing?

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Remember to use the category slugs - not the displayed names.

Topic Closed

This topic has been closed to new replies.

About this Topic