Support » Themes and Templates » display the excerpt of a recent catergory post

  • Resolved ethicus

    (@ethicus)


    Hi there I´ve managed to make a page that loads recent post of different categories. code looks like this:

    <?php $recent = new WP_Query("cat=8&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
                 <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
                 <?php the_content('Read more'); ?>
                <?php endwhile; ?>

    The post with cat id 8 has a more tag in it, but i don’t see the read more link in the output can someone help me out on this one?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try this before the_content

    <?php global $more; $more = 0; ?>

    <?php $recent = new WP_Query("cat=8&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
                 <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    <?php global $more; $more = 0; ?>
                 <?php the_content('Read more'); ?>
                <?php endwhile; ?>

    this don’t work…

    Hmm; what about:
    global $wp_query;
    $wp_query->in_the_loop = true;

    Nope that wont do it neither :o(

    I’m sorry i’ve put in a post that doesn’t have the more tag in it DUH!
    Could you tell me what the extra code does?

    THIS CODE WORKS!

    <?php $recent = new WP_Query("cat=5&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
                 <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    			<?php global $more; $more = 0; ?>
                 <?php the_content('Read More..'); ?>
                <?php endwhile; ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘display the excerpt of a recent catergory post’ is closed to new replies.