How do I show a custom field meta without the key's name? (3 posts)

  1. mediabaron
    Posted 6 years ago #

    I set-up a Custom Field with name=map and value=Google map embed code

    I went to my single post theme template and added the code
    <?php the_meta(); ?>

    In the post I get the Google Map to display properly but to the left of the map it displays 'map:'

    Without the quotes of course. How do I get the custom field (in this case the Google Map) to display without they name key showing?

    I know I could just paste the embedded Google Map code directly into the post but if the editing window is switched to Visual it usually messes up the Google Map code.

    I figure this should be an easy one for those familiar with php out there (me not).

  2. esmi
    Forum Moderator
    Posted 6 years ago #

  3. mediabaron
    Posted 6 years ago #

    I had gone to that page, that's how I got the original <?php the_meta(); ?> code.

    After some digging and trial and error I was able to answer my own question (notice I had said I'm not a php whiz). If someone thinks there's a better way let me know. All I know now is that this solution works so far.

    I used this code in my theme template and it seems to be okay.
    <?php $key="map"; echo get_post_meta($post->ID, $key, true); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic