• Resolved Floyd3

    (@floyd3)


    In each post, I have a custom field that looks like this:

    <a href="http://www.mysite.com/albumtitle">Album Title</a>

    Using the following code, I can display the custom field anywher I want: <?php echo get_post_meta($post->ID, 'album', true); ?>

    And it works, it displays the above custom field, HTML included, as it should…

    But what do I do, if I just want to display the Album Title part of the custom field – and not the HTML/URL surrounding it?

    Something to do with echo get_post_meta AND strip tags, or something possibly?

Viewing 1 replies (of 1 total)
  • Thread Starter Floyd3

    (@floyd3)

    Woo! Twas not easy, but I found it… In case anyone happens to have a need for this in the future, here’s the code I used:

    <?php $album = strip_tags(get_post_meta($post->ID, 'album', true));
    echo substr($album, 0, 100) . ""; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘PHP Echo just the text of a custom field’ is closed to new replies.