php - wordpress get_excerpt() in loop -


update: found work around, listed below. new wordpress of today. can't seem "the_excerpt" in loop. either not show or posts on first one. ideas?

it's towards bottom trying insert it.

<? if(!$_get[id]) {     $args = array( 'numberposts' => '5' );     $recent_posts = wp_get_recent_posts( $args );     start_wp();     foreach( $recent_posts $recent ) {         set_post_thumbnail_size( 33, 33);          $excerpt = get_the_excerpt();         { ?>          <table width="100%" cellpadding="0" cellspacing="0" id="blogholder">   <tr>     <td width="21%" rowspan="2" align="center" valign="middle"><div class="blogimage"><? echo get_the_post_thumbnail($recent["id"], array(133,133) ); ?></div>      <img src="images/blogimagebox.png" width="177" height="177" /></td>     <td width="79%" height="23" valign="middle" class="blogtitle"><? echo $recent["post_title"]; ?></td>   </tr>   <tr>     <td height="24" valign="middle" class="blogtitle"><? echo $excerpt; ?></td>   </tr>   <tr>      </tr> </table>   <? }        } }/// end if no id ?> 

update: found work around.

<? if(!$_get[id]) {   $posts = get_posts();  foreach ($posts $post) : start_wp(); ?>           <table width="100%" cellpadding="0" cellspacing="0" id="blogholder">   <tr>     <td width="21%" rowspan="2" align="center" valign="middle"><div class="blogimage"><? echo get_the_post_thumbnail($recent["id"], array(133,133) ); ?></div>      <img src="images/blogimagebox.png" width="177" height="177" /></td>     <td width="79%" height="23" valign="middle" class="blogtitle"><? echo the_title(); ?></td>   </tr>   <tr>     <td height="24" valign="top" ><blockquote class="blogcontent">       <p><? echo the_excerpt(); ?></p>     </blockquote></td>   </tr>   <tr>      </tr> </table>   <?php endforeach;  } ?> 

you should use loop syntax, wp_start(); deprecated since 1.5.

if( have_posts() ) : while( have_posts() ) : the_post();   //display single post title   the_title();    //display post thumbnail image   if( has_thumbnail ) : the_post_thumbnail();    //display post excerpt   the_excerpt();  endwhile; endif; 

you can run own query using wp_query class or get_posts();. note: if use 1 or more loop in same page remember wp_reset_postdata();

//set array of arguments, please check wp_query/get_posts() docs please $args = array( 'posts_per_page' => '5' ); $query = new wp_query( $args );  if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_posts(); //display single post title   the_title();    //display post thumbnail image   if( has_thumbnail ) : the_post_thumbnail();    //display post excerpt   the_excerpt();  endwhile; wp_reset_postdata(); endif; 

hope helps!


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -