How to link up “read more” on excerpts hack from WP Recipies
Replace the last row of code from: return $content; To: return $content.'<a href=”‘.get_permalink($post->ID).'”>Read More…</a>’;
Replace the last row of code from: return $content; To: return $content.'<a href=”‘.get_permalink($post->ID).'”>Read More…</a>’;
/** * @author: wpreceipes * @link: [1]: http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it */ function wpse18215_catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all( ‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches ); $first_img = $matches[1][0]; //Defines a default image if( empty( $first_img ) ) { $first_img = ‘/images/default.jpg’; } return $first_img; } Example: echo catch_that_image(); or: /** * @author: Marcelo … Read more
The Easiest way to do that would be to use List category posts plugin which allows you to list posts from a category into a post/page using the [catlist] shortcode. you can also use this shortcode in a simple text widget and add just add : add_filter(‘widget_text’, ‘do_shortcode’); to your theme’s functions.php file, which will … Read more
You can use get_post_type add_filter(‘excerpt_more’, ‘new_excerpt_more’); function new_excerpt_more($more) { global $post; $post_type = get_post_type($post); switch( $post_type ): case ‘event’: $teaser=”<a class=”moretag” href=””. get_permalink($post->ID) . ‘”> More events </a>’; break; case ‘post’: $teaser=”<a class=”moretag” href=””. get_permalink($post->ID) . ‘”> … </a>’; break; default $teaser=””; endswitch; return $teaser; }
Some questions are easily solved searching this Stack and joining some answers together. Bulk post type conversion Automated adding of one tag to all the posts in a category The following plugin will run the conversion code when activated. Adjust the $tags array, and don’t forget to backup your database before proceeding. <?php /* Plugin … Read more
You could make use of wp_trim_words: <p><?php echo wp_trim_words( get_post_meta( $post->ID, ‘twpb_news_textnews’, true ), 55, ‘[…]’ ); ?></p> Or, if you want the filters applicable to the regular excerpts to be used as well, write your own wrapper for it: function wpse115106_news_excerpt( $text=”” ) { $excerpt_length = apply_filters( ‘excerpt_length’, 55 ); $excerpt_more = apply_filters( ‘excerpt_more’, … Read more
I think you need to use mb_strimwidth function for trim the characters instead of words. echo mb_strimwidth(get_the_title(), 0, 40, ‘…’);
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
In the twenty fourteen theme there is a plugable function named twentyfourteen_excerpt_more which generates the read more links. This function can be overridden in your child theme to use your custom read more link. All you need to do is add the following to your child theme’s functions.php file: /** * Overrides the parent function … Read more
You can modify the […] with simple function you place in functions.php function wpdocs_excerpt_more( $more ) { return ‘<a href=”‘.get_permalink( get_the_ID() ).'”>[…]</a>’; } add_filter( ‘excerpt_more’, ‘wpdocs_excerpt_more’ );