WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get a "limited" Excerpt from Custom Field Text? (3 posts)

  1. arthurdent2003
    Member
    Posted 3 years ago #

    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

  2. arthurdent2003
    Member
    Posted 3 years ago #

    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));
    		}
    		?>

  3. daveleeone
    Member
    Posted 2 years ago #

    thanks for reply

Topic Closed

This topic has been closed to new replies.

About this Topic