WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Get a "limited" Excerpt from Custom Field Text?

[Resolved] Get a "limited" Excerpt from Custom Field Text?

  • Hi!

    I have a qustion about an excerpt from a custom field.

    How can I limit the number of words from a text out of a custom field?

    I would like to use this text as kind of excerpt.

    I know how to limit the number of words for the excerpt – but I don’t know how to make it work out a custom field – any Idea?

    THANK YOU! 🙂

    AD

Viewing 2 replies - 1 through 2 (of 2 total)
  • Got it working: Maybe you may need it: Thanks to the forum:

    <?php $trim_length = 450;  //desired length of text to display
    		$custom_field = 'Custom Field';
    		$value = get_post_meta($post->ID, $custom_field, true);
    		if ($value) {
    		  echo rtrim(substr($value,0,$trim_length));
    		}
    		?>

    thanks for reply

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Get a "limited" Excerpt from Custom Field Text?’ is closed to new replies.