/ Published in: PHP
Por parámetro selecciono la cantidad de caracteres que quiero que me muestre the_excerpt() en wordpress
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
global $post; $args = array('numberposts' => 3, 'offset'=> 0, 'order'=> 'DESC' ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); $excerpt = get_the_excerpt(); add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 145, 100, true ); // Normal post thumbnails add_image_size( 'single-post-thumbnail', 400, 9999 ); // Permalink thumbnail size ?> <div class="homepostd"> <div class="thumbd"> <a title="<?php the_title(); ?>" rel="bookmark" href="<?php the_permalink(); ?>"> <?php if(has_post_thumbnail()) { } else { echo '<img src="'.get_bloginfo("template_url").'/images/img-default.jpg" width="150" height="64" />'; } ?> </a> </div> <div class="rightcontpd"> <b><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></b> <?php echo string_limit_words($excerpt,10);?><a href="<?php the_permalink(); ?>">[...]</a> </div> </div> <?php endforeach; ?>