Support » Fixing WordPress » Pulling posts from certain category and applying different style to only first.

  • If I want to pull only from a certain category, where would I put that call?

    Using this:

    <?php if (have_posts()) : ?>
    <?php $post = $posts[0]; $c=0;?>
    <?php while (have_posts()) : the_post(); ?>
    
    <?php $c++;
    if( $c == 1) :?>
    <h1>The first post on the main index page</h1>
    <?php the_title(); ?>
    <?php the_excerpt(); ?>
    
    <?php else :?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endif;?>
    
    <?php endwhile; ?>

    I was using this:

    <?php
    query_posts("cat=16");
    global $more;
    // set $more to 0 in order to only get the first part of the post
    $more = 0;
    ?>

    But obviously this lacks the style changes. Not sure how to combine…

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    (@esmi)

    Forum Moderator

    Try:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 16,
    	'paged' => $paged
    );
    query_posts($args);
    ?>
    <?php if (have_posts()) : ?>
    <?php $post = $posts[0]; $c=0;?>
    <?php while (have_posts()) : the_post(); ?>
    [...]

    Sorry, I’m still a bit new at this, how can I use what you have shared, and still have the first styled differently as in my example?

    Thanks again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pulling posts from certain category and applying different style to only first.’ is closed to new replies.