Forums

custom field - FOR PAGE - remove key value (9 posts)

  1. pddiaz
    Member
    Posted 1 year ago #

    I am trying to use the - <?php the_meta(); ?> FROM A PAGE - to grab a custom field, but I would like to get the value of a field (in this case its name is 'review') without the name coming up('review') in front of it.

    Can anybody help me edit my function to get this going?

    Also, if I add a new field, how can I specifically call that field?

    any help is greatly appreciated..

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

  3. pddiaz
    Member
    Posted 1 year ago #

    Thanks, I just can't seem to figure out how to add code to not show the custom field name? Any ideas?

  4. MichaelH
    Volunteer
    Posted 1 year ago #

    <?php
    $review = get_post_meta($post->ID, 'review', true);
    if (review){
    echo review;
    }
    ?>
  5. pddiaz
    Member
    Posted 1 year ago #

    I tried this but it simply echo's 'review' instead of the custom field without that name..

  6. MichaelH
    Volunteer
    Posted 1 year ago #

    echo $review;
  7. pddiaz
    Member
    Posted 1 year ago #

    Hi MichaelH, thanks for your continued help, but the $review didn't work either, I don't get an error, I just get a blank.

    This is a custom field for a PAGE, not a post, would that have something to do with it?

    the_meta() works but not get_post_meta....

    thanks for your continued help with this...

  8. MichaelH
    Volunteer
    Posted 1 year ago #

    Then make sure you are using that in a loop where $post->ID is a valid value.

    If necessary paste all the code from that template (Page Template) at wordpress.pastebin.com and report the link back here and maybe someone can spot the problem.

  9. pddiaz
    Member
    Posted 1 year ago #

    is it possible to get the the_meta() outside the loop without the key value? My div structure is such that it is outside the loop....

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.