Support » Fixing WordPress » Limit amount of words displayed without using the_excerpt or <!–more–>

  • Hi all,

    I’ve been searching for this for hours and surprisingly come up with nothing. I am using the great “more fields” plugin here:

    When I output the content, I want to have a landing page with the intro text for each post. I would like to just grab the first 50 words of text or so from the post and show them only with at “read more” link to the post.

    Is there a way to control the amount of words output on any type of content? My line of code is:
    <?php meta(‘body-text’); ?>

    Any help would be greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • From The Excerpt Reloaded by Kaf:

    the_excerpt Reloaded, when a post does not contain an excerpt, displays the contents of the post (typically abbreviated), which can be customized on which HTML tags to allow, length of the excerpt (in words), “more…” link, and filtering type.

    If you use that plugin, please review:

    Thanks for your prompt reply Michael, I really appreciate it.

    I have installed the excerpt_reloaded plugin, but I think the problem is that it is applied to the_content field. In this instance, I would like to be able to apply it to another field I have created using the “more fields” plugin.

    Which was this one:
    <?php meta(‘body-text’); ?>

    Do you know if there is a way of doing that?

    The more fields plugin author has examples of code at

    Something like:

      if ($bodytext = get_meta('body-text'))
      echo 'Text: ' . $bodytext;

    Thanks for your reply Michael. I couldn’t get is working with the excerpt, so I got the PHP developer here to help me out. Here is what he came up with:

    <?php $temp_query = $wp_query; ?>
    <?php if (have_posts()) : ?>
    <?php query_posts(array(
    	'post_status' => 'publish',
    	'static' => true,
    	'post_per_page' => '2',
    	'showposts' => '2',
    	)); ?>
    <?php static $ctr = 0; 	?>
    <?php while (have_posts()) : the_post(); ?>
    	<?php if ($ctr == "2") { break; } else { ?>
    	<dt><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></dt>
    		<div class="thumbnail"><?php meta('thumbnail-graphic'); ?></div>
    		<?php if ($introtext = get_meta('intro-text')){
    			if (strlen($introtext) > 55){
    				$words = str_word_count($introtext, 2);
    				$pos = array_keys($words);
    				$introtext = substr($introtext, 0, $pos[55]) . '...';
    			echo $introtext;
    		<p><a class="arrowLink" href="<?php the_permalink() ?>">Read more</a></p>
    	<?php $ctr++; }?>
    $wp_query = $temp_query;

    Works a treat

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Limit amount of words displayed without using the_excerpt or <!–more–>’ is closed to new replies.