WordPress.org

Ready to get started?Download WordPress

Forums

2.6: image excerpts not working? (2 posts)

  1. slambert
    Member
    Posted 6 years ago #

    Hi,

    I've been using WP for several years and this is stumping me.

    Here's the site:

    http://visitsteve.com

    On the lower left I have a display of excepts from a specific category in the home.php template. I am using multiple loops to display these. They are text - they work.

    On the lower right I have a display of excepts (I'm using images here) from a specific category. Also using a special loop here.

    The problem is: the images stopped showing up on the right when I updated to WP 2.6.

    I'm using the Content Extract Plugin as well. Not sure that it's a factor.

    Here's the code for the column on the left:

    <div id="home-news">
    		<h2>Recent News</h2>
    		<?php $posts = get_posts( "category=1&numberposts=5" ); ?>
    		<?php if( $posts ) : ?>
    		<ul id="news-list">
    		<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    		<li>
    		<span class="title">
    		<a href="<?php the_permalink() ?>">
    		<?php the_title(); ?>
    		</a></span>
    		<span class="date">
    		<?php the_time('F j'); ?>
    		</span>
    		<?php the_excerpt(); ?>
    		</li>
    		<?php endforeach; ?>
    		</ul>
    		<?php endif; ?>
    	</div>

    And the column on the right which isn't working:

    <div id="home-work">
    		<h2>Recent Work</h2>
    		<?php $posts = get_posts( "category=9&numberposts=6" ); ?>
    		<?php if( $posts ) : ?>
    		<ul id="work-list">
    		<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    		<li>
    		<a href="<?php the_permalink() ?>">
    		<?php wswwpx_content_extract ( '', 10, 10, false, '', '', true, false ); ?></a>
    		<a href="<?php the_permalink() ?>"><span class="title">
    		<?php the_title(); ?>
    		</span></a>
    		</li>
    		<?php endforeach; ?>
    		</ul>
    		<?php endif; ?>
    	</div>

    Clues, code, hunches?

  2. slambert
    Member
    Posted 6 years ago #

    I fixed this by replacing the code using get_posts with query_posts

    Before:
    <?php $posts = get_posts( "category=9&numberposts=6" ); ?>

    After:
    <?php $posts = query_posts( "cat=9&posts_per_page=6" ); ?>

    I also added more detailed info about this problem and my troubleshooting to this ticket: http://trac.wordpress.org/ticket/7326#comment:5

    Hope this helps someone.

Topic Closed

This topic has been closed to new replies.

About this Topic