New answers tagged

0

Put the following code in your functions.php function excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } ...


0

Answering my own question. Solved with an if else statement using has_excerpt. if( has_excerpt ( $_post, ID ) ) { $author = sprintf( '<a href="%1$s">Apply</a>', esc_attr( get_the_excerpt( $_post ) ) ); } else { $author = ''; } It only makes sense, really.


0

If you have a look at how [dj-widget] shortcode is handled you will get an idea of how to implement plugin authors' idea of showing post description. if($show_desc) { $desc_string = station_shorten_string(strip_tags($show->post_content), 20); $output .= '<span ...


0

I view get_the_excerpt() as a function with legacy design. As WordPress usage has grown there are many newer use-cases where it doesn't fit but where the newer functions for getting different data do. One example is the now frequent use of an $args array of function options. But it's easy to fix for your needs. Here's an alternative function you can use ...


0

You can use has_excerpt() for this, which checks whether the post has a manually set excerpt. The sample code below uses this function: <?php if ( has_excerpt() ) : // Only show custom excerpts not autoexcerpts ?> <span class="entry-subtitle"><?php echo get_the_excerpt(); ?></span> <?php endif; ?>



Top 50 recent answers are included