• Resolved guided

    (@guided)


    I’m trying to display all the posts, up to the more tag, from a given category at the bottom of my Kungfu Holidays page.

    I’ve tried a number of approaches, but had no luck. At the moment I’m using the ‘Latest Posts by Category Archive WP Plugin’ but that strips the formatting and restricts the exceprt length.

    I’d like the posts to keep the formatting of my archives, here.

    Any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi

    I’ve not used this plugin, but it sounds like it might do what you want.
    http://wordpress.org/extend/plugins/post-teaser/
    You would use it with a custom query loop at the bottom of the page. The plugin appears to override the default the_excerpt() code, so you activate it with the_excerpt() but its code runs instead – respects the <!-- more --> tag

    <?php
    $catPosts = new WP_Query();
    $catPosts->query(‘showposts=5&cat=5’); // use your cat ID code
    while ($catPosts->have_posts()) : $catPosts->the_post(); ?>
    <h3>” rel=”bookmark”><?php the_title(); ?></h3>
    <?php the_excerpt();
    endwhile; ?>

    screwed up the code – should be this

    <?php
    $catPosts = new WP_Query();
    $catPosts->query('showposts=5&amp;cat=5'); // use your cat ID code
    while ($catPosts->have_posts()) : $catPosts->the_post(); ?>
      <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
      <?php the_excerpt();
    endwhile; ?>
    Thread Starter guided

    (@guided)

    Thanks stvwlf. I had given up on this, and was going to find a less satisfactory workaround. Your help got me to give it another go.

    I’ve managed to get something resembling what I want, which, with a little styling, should be just about right.

    I used a mixture of antistandard’s solution, found here, and a solution I found in the codex, here.

    My code, placed after page.php’s <?php endwhile; endif; ?> looks like this:

    <?php query_posts('cat=255');?>
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    	<?php
    		// Display content above the more tag
    		$more = 0;
    		the_content("More...");
    	?>
    
    	<?php endwhile; else: endif; ?>

    Not sure if that’s the neatest way to do it, but it seems to work.

    Thread Starter guided

    (@guided)

    Oh, I should mention that I had to place the code below outside the loop.

    <?php
    		// Declare global $more, before the loop.
    		global $more;
    	?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying posts from a category within a static page’ is closed to new replies.