• Resolved dw

    (@daleanthony)


    Not sure if this is something to do with 2.6 beta 1 or if it’s just a coincidence that this problem started just after I upgraded my installation.

    I have a page template (see code below) to show posts from category ‘8’ which worked fine before, but now it seems to be showing posts from all categories. (live page at https://www.daleanthony.com/portfolio/)

    If this isn’t a bug and it’s just me being silly I would appreciate it if someone could offer some advice on how to fix this problem.

    <?php get_header(); ?>
    
    			<div id="content-container-wide">
    
    			<ul class="portfolioul">
    		 	<?php global $post; $myposts = get_posts('numberposts=9&offset=0&category=8'); foreach($myposts as $post) : setup_postdata($post); ?>
    
    				<li>
    				<img src="<?php echo get_post_meta($post->ID, "port-thumb", true); ?>" alt="<?php the_title(); ?> - Thumbnail"/>
    				<span class="portfolio-title"><?php the_title(); ?></span>
    				<span class="portfolio-work"><?php echo get_post_meta($post->ID, "port-project", true); ?></span>
    				<div class="portfolio-description"><?php the_content(''); ?></div>
    				</li>
    
    		 	<?php endforeach; ?>
    			</ul>
    		</div>
    
    		<div id="content-footer-wide"></div>
    
    </div>
    
    	<?php get_footer(); ?>

    Cheers.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Erm, I got a feeling that method of retrieving post is quite backdated. Correct me if I am wrong. You should use query_post() instead.

    Thread Starter dw

    (@daleanthony)

    @gamerz thanks for the pointer, not quite sure how to get the template working with query_post though. It looks a bit more complicated than get_posts.

    thanks Michael! Yours is a much better link =p

    Thread Starter dw

    (@daleanthony)

    Any possibility someone could spare me 5 minutes to help re-write my portfolio page with query_posts? I’ve confused myself with it.

    <?php get_header(); ?>
    <div id="content-container-wide">
    	<ul class="portfolioul">
    <?php
    	query_posts('showposts=9&offset=0&cat=8');
    	while (have_posts()) : the_post();
    ?>
    
    <li>
    			<img src="<?php echo get_post_meta($post->ID, "port-thumb", true); ?>" alt="<?php the_title(); ?> - Thumbnail"/>
    			<span class="portfolio-title"><?php the_title(); ?></span>
    			<span class="portfolio-work"><?php echo get_post_meta($post->ID, "port-project", true); ?></span>
    			<div class="portfolio-description"><?php the_content(''); ?></div>
    		</li>
    <?php endwhile; ?>
    
    </div>
    <div id="content-footer-wide"></div>
    </div>
    <?php get_footer(); ?>

    The code is untested =D

    Thread Starter dw

    (@daleanthony)

    @gamerz Thanks for the help… I tried the code but it didn’t work, played around with some of my wordpress settings and realised that a plugin was causing the problem which is probably why I couldnt get it working myself.

    Thanks again though!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘2.6 beta 1 get_posts bug?’ is closed to new replies.