New answers tagged

0

I think you can simplify your code a lot, by just using: $episode_number = ( $query->found_posts - $query->current_post ); in the loop as the episode's number. So you don't need that problematic Get_Post_Number() function and there's no need to use a special shortcode for this.


0

It seems you need to rest the post data before return the $postCount. Before return it, add the follow: wp_reset_postdata(); -- There is a difference between wp_reset_query()and wp_reset_postdata(), as explained here. wp_reset_query() - ensure that the main query has been reset to the original main query. wp_reset_postdata() - ensures that the global $...


1

This has to work, Im using it in several projects: add_filter( 'excerpt_more', 'my_excerpt_more' ); function my_excerpt_more( $more ) { return ''; } Just copy-paste it to your functions.php. Little bonus snippet that you might need: add_filter( 'excerpt_length', 'my_excerpt_length' ); function my_excerpt_length( $length ) { return 50; } ...


1

Try to create a new function in your functions.php: function custom_excerpt() { $text=preg_replace( "/\\[&hellip;\\]/",'place here whatever you want to replace',get_the_excerpt()); echo '<p>'.$text.'</p>'; } Then use the new function on your page.


4

Try the filters in your functions.php: add_filter( 'the_excerpt', 'shortcode_unautop'); add_filter( 'the_excerpt', 'do_shortcode'); Props: @bainternet (Source) Or, use your own filter on get_the_excerpt. Put this in your theme's functions.php: function custom_excerpt($text = '') { $raw_excerpt = $text; if ( '' == $text ) { $text = ...


1

Try ltrim() to remove characters at the begining of a string. $str = '&nbsp;&nbsp; Some Stuff here this is ok and &nbsp;&nbsp;&nbsp; this is'; echo ltrim(ltrim($str, '&nbsp;'), ' ');


0

This is a little two-liner I use a lot utilizing wp_trim_words. I constantly finding myself needing the abbreviation and read more functionalities outside of the loop. Some one else may find this useful. So this is what I use to: Get the Excerpt by POST ID Get Post Content If no Excerpt has been set, Set the Word length of the Excerpt Choose the Content ...


-1

Depending on where in the loop you call excerpt() wpautop might be creating the <p>...</p> wrapper. In that case, you could wrap $excerpt with <p>...</p> before returning it. Edit: Try this approach <?php echo excerpt(25)."\n";?> (or possibly "\n\n") to change the behavior. in function awesome_excerpt() you have $text = ...



Top 50 recent answers are included