How to limit 1 image per post on homepage only?

/** * @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

Add $more_link_text parameter to the_excerpt()

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) . ‘”> &hellip; </a>’; break; default $teaser=””; endswitch; return $teaser; }

make a excerpt on data from a meta box?

You could make use of wp_trim_words: <p><?php echo wp_trim_words( get_post_meta( $post->ID, ‘twpb_news_textnews’, true ), 55, ‘[&hellip;]’ ); ?></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

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

Twenty Fourteen: Change Read More text

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