• Resolved a-kyle

    (@a-kyle)


    SO I have this piece of code that should display the posts of the selected categories by their ID. this piece of code is in both the footer and the drop down menu.

    on my home page (a static page) it displays ONE post that when clicked on goes no where, and the same goes for the drop down.

    on the blog page it displays up to 10 or more posts when it should only display 5.

    can some one tell me what’s wrong with this code?

    <h4><?php _e('Recent Posts'); ?></h4>
    			<?php query_posts('showposts=5','cat=3,4,9,13,5,6,15,7');
    			wp_reset_query();?>
    
    			<?php while (have_posts()) : the_post(); ?>
    				<li><em>(<?php the_time('M d') ?>)</em><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li>
    			<?php endwhile;?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php query_posts('showposts=5','cat=3,4,9,13,5,6,15,7');
    Incorrect format. Try:
    <?php query_posts('posts_per_page=5&cat=3,4,9,13,5,6,15,7');

    wp_reset_query();
    Should be after the Loop – not before it. You’re destroying the custom query that you just created.

    I’d suggest reviewing some of the examples on http://codex.wordpress.org/Function_Reference/query_posts#Category_Parameters

    Thread Starter a-kyle

    (@a-kyle)

    Thanks for the help but that did nothing for me. For example on the local host I have blog posts (test posts) going back as far as the 22nd of may. (fixed a date error)

    on the main site, the actual site, their is no post going back that far and yet I am getting a test post to show up called Adam. this data base and word press installation isn’t even 2 weeks old.

    0o

    I am assuming the code should look like:

    <h4><?php _e('Recent Posts'); ?></h4>
    
    			<?php while (have_posts()) : the_post(); ?>
    				<li><em>(<?php the_time('M d') ?>)</em><a href="<?php the_permalink() ?>">				<?php the_title(); ?></a> </li>
    			<?php endwhile;?>
    
    		<?php query_posts('posts_per_page=5&cat=3,4,9,13,5,6,15,7');
    			wp_reset_query();?>
    Anonymous User

    (@anonymized-3085)

    try:

    <h4><?php _e('Recent Posts'); ?></h4>
            <?php query_posts('posts_per_page=5&cat=3,4,9,13,5,6,15,7'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	   <li><em>(<?php the_time('M d') ?>)</em><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li>
    	<?php endwhile;?>
            <?php wp_reset_query();?>

    Thread Starter a-kyle

    (@a-kyle)

    Ya I figured that out last minute. LOL Thanks guys

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

The topic ‘Help with query posts’ is closed to new replies.