How to wrap “Read More” link in a DIV tag?
Put a filter on the_content_more_link. Untested but… function wrap_more_link($more) { return ‘<div>’.$more.'</div>’; } add_filter(‘the_content_more_link’,’wrap_more_link’);
Put a filter on the_content_more_link. Untested but… function wrap_more_link($more) { return ‘<div>’.$more.'</div>’; } add_filter(‘the_content_more_link’,’wrap_more_link’);
the_content() does not grab the PHP file content.php, it simply displays a Post’s content. Likewise, the_excerpt() grabs the excerpt of a post. get_template_part simply finds a file within your theme named whatever you put in, with an optional suffix. get_template_part( ‘content’ ); // content.php get_template_part( ‘content’, ‘my_page’ ); // content-my_page.php in order for make different … Read more
You may try the following code. $content = get_the_excerpt(); $content = preg_replace(“/<img(.*?)>/si”, “”, $content); echo $content; preg_replace will remove the image tag content from the post content.
Yes, you can do that, but you’ll need to tweak the <?php the_excerpt(); ?> function. This is a good article on how to do that: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ To sum up the article in case it goes away, put this in your theme’s functions.php file: function improved_trim_excerpt($text) { global $post; if ( ” == $text ) { … Read more
Try this one /* Change Excerpt length */ function excerpt($num, $post_id) { // removed empty default value $limit = $num+1; $excerpt = apply_filters(‘the_excerpt’, get_post_field(‘post_excerpt’, $post_id)); $excerpt = explode(‘ ‘, $excerpt, $limit); array_pop($excerpt); $excerpt = implode(” “,$excerpt).”…”; echo $excerpt; } Another solution – using setup_postdata($post); and wp_reset_postdata(); function custom_get_the_excerpt($post_id) { global $post; $save_post = $post; $post … Read more
There’s a discussion on WP Support Forum that was related to your question. The pastebin constains the function stated in the other answer. I’ve decreased the priority to 5 and it works on my test theme. add_filter( ‘get_the_excerpt’, ‘wp_strip_header_tags’, 5); If you want to target only <h3> you can use this regex: $regex = ‘#(<h([3])[^>]*>)\s?(.*)?\s?(<\/h\2>)#’;
The excerpt filter by default cuts your post by a word count, which I think is probably preferable to a character-based substr function like you’re doing, and it strings out tags and images as well while doing it. You can set the number of words to excerpt with the filter excerpt_length (it defaults to 55 … Read more
I have reproduced your environment using the same theme and the same plugin. Out of the box, the plugin does not register the CPT with excerpt. You need to register it: add_post_type_support(‘advert’, array(‘excerpt’)); This should go in functions.php of your (child?) theme. My only question is: how and why were you getting excerpts on singular … Read more
I too am looking for this option / feature. I came across this guys explanation which I believe answers most of the question. I am in the process of implementing this so I cannot say how accurate it is being a wordpress noob (not php!), I do realise this is for a custom box but … Read more
Go to settings> reading in your WordPress dashboard and change the setting from full text to summary.