Tag Info

New answers tagged

2

The get_template_part('content', get_post_format()); line includes content from one of the other files in your theme based on the post type, the file name will be something like content-page.php (or content.php if the format is not found). If you print out what get_post_format() returns, you will be able to tell which content file to look into. Once you ...


-3

The issue is occurring because of the get_template_part function. It is including the template file which prints the complete text. What should be done is, instead of making changes in the Original theme itself, first you should create a child theme. Reason behind this is, you can safely upgrade your original theme when Theme author releases new version. If ...


0

The twentyfourteen index page calls get_template_part( 'content', get_post_format() ); inside the loop. So the content of the loop resides in template files with the name content-{$post_format}.php. All posts that does not have a post format uses content.php to display the post data If you look at content.php, these lines are where the content is ...


0

With the recent version of Wordpress (v.3.3.0+), you can actually use wp_trim_words. function excerpt($limit) { return wp_trim_words(get_the_excerpt(), $limit); } See also: http://stackoverflow.com/a/17177847/851045


0

What about using this function in functions.php: function new_excerpt_length($length) { return 20; } add_filter('excerpt_length', 'new_excerpt_length'); And then getting it by adding<?php the_excerpt()?> to php template? OR: <?php $string = get_the_excerpt(); if (strlen($string) <=20) {echo '' . $string . '';} else {echo '' . ...


2

Assuming your content is in the variable $content you would begin by removing all html tags using wp_strip_all_tags: $new_content = wp_strip_all_tags( $content ); Then you will want to trim that to 200 characters using substr: $new_content = substr( $new_content, 0, 200 ); To retrieve the YouTube video, you'll need to use preg_match: preg_match( ...



Top 50 recent answers are included