Read more on the post page itself

The solution might depend on why exactly you want it to work that way on the post page. But probably the best way would be to do this on the client side. Method with maximum height Let’s say your post template has its content like this: <div id=”content”><?php the_content(); ?></div> You need to add a … Read more

Different ‘read more’ links

How about using condition to change the readmore links. Here is an sample code which returns a different read more text based upon the category of post. You should read the official codex page to know more about other conditional tags you can use in wordpress. Usage – put this code into your theme’s functions.php … Read more

How to only show the first X words (from each post) on the home page?

Changing the word count on the home page is easy: if( is_home() ) add_filter( ‘excerpt_length’, create_function( ”, ‘return 300;’ ) ); Just replicate that code and change the conditional check to add this to other pages. The other option is to just insert the code on the template page (home.php, tag.php, etc.), so you know … Read more

Custom excerpt showing first paragraph (with HTML formatting)

Here is a function that keeps HTML tags in tact, adds a “Read More” link at the end of the excerpt and trims the excerpt after the first paragraph. if ( ! function_exists( ‘wpse0001_custom_wp_trim_excerpt’ ) ) : function wpse0001_custom_wp_trim_excerpt($wpse0001_excerpt) { global $post; $raw_excerpt = $wpse0001_excerpt; if ( ” == $wpse0001_excerpt ) { $wpse0001_excerpt = get_the_content(”); … Read more

“More” span making trouble

So, two separate issues – links not displaying and faulty markup? For links not displaying – check if your template uses the_content() function, more functionality doesn’t display links after the_excerpt(). For markup I find that you need blank lines around more for everything to work properly. So this can cause markup issues: Some text here. … Read more

Text after more tag in posts

This will add your code after the more tag area on the post page: add_filter(‘the_content’, ‘adds_block’); function adds_block($content) { if (is_single()) { // return $content; global $post; $thePostID = $post->ID; $test=”<span id=”more-” .$thePostID.'”></span>’; return str_replace($test, ads(), $content); } } function ads(){ return ‘Your Custom Code,,’; }

“Read more” link doesn’t show up when the post length is under the excerpt length

The reason is the following check in the wp_trim_words() function: if ( count( $words_array ) > $num_words ) { array_pop( $words_array ); $text = implode( $sep, $words_array ); $text = $text . $more; } else { $text = implode( $sep, $words_array ); } You can therefore try the following: add_filter( ‘wp_trim_words’, function( $text, $num_words, $more … Read more

Word limit in post_content after more tag

Use wp_trim_words function to limit the content to a certain number of words and returns the trimmed text. Example use of wp_trim_words function. <?php $content = get_the_content(); $trimmed_content = wp_trim_words( $content, 50, NULL ); echo $trimmed_content; ?> So I added wp_trim_words function in your code to get 50 words after <!– more –>. <?php $after_more … Read more