How to make a button?

The “(more…)” link gets filtered through the_content_more_link in get_the_content(). You can hook into this function and let it return whatever you want. add_filter(‘the_content_more_link’, ‘more_button’); function more_button($more_link) { return ‘<button class=”readmorebtn” onclick=”‘ . esc_attr(‘window.location=”‘ . get_permalink() . ‘”‘) . ‘”>Read more</button>’; }

How to get the excerpt of a page before more tag?

The content is manipulated by the get_the_content function, and that function always assumes the current post in the Loop. You can’t pass it an ID, strangely. The easiest way to get just the bit before the more for an arbitrary post ID is: $p = get_post(1); $p = preg_split( ‘/<!–more(.*?)?–>/’, $p->post_content ); echo $p[0]; There … Read more

Get the link text

You can use posts custom fields to store a custom continue reading text for each post, and then use that value in the_content_more_link filter. For example you might have a custom field with meta key of continue_reading to enable users to specify the custom Read More text, and use that value like: add_filter(‘the_content_more_link’, ‘ad_contiue_reading_text’,10,2); function … Read more

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

Exclude filter on front page

You can just remove the filter before calling the_excerpt and then add it back afterwards… remove_filter(‘excerpt_more’,’new_excerpt_more’); the_excerpt(); add_filter(‘excerpt_more’, ‘new_excerpt_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,,’; }