All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Display metaData except for “Price” or “Download”

  • # April 19, 2013 at 10:06 am

    How do I make a for-loop that will display all the metaData except for what has a name of “Price” or the name “Download”

    Right now I’m using < ?php the_meta(); ?> which just shows everything.

    # April 19, 2013 at 10:46 am

    This look shows everything with the label Downloads. Now how can I switch this around to show everything except for download along with the name of the Value as the label….?

    < ?php
    //Get any custom field data under the name Downloads and display
    $downloadField = get_post_meta($post->ID, ‘Downloads’, true);
    if ($downloadField) {
    $custom_fields = get_post_meta( get_the_ID() );
    $my_custom_field = $custom_fields;
    foreach ( $my_custom_field as $key => $value )
    echo “

    ” . $value . “

    ” ;
    else {

    # April 19, 2013 at 2:50 pm

    check the key of the meta data and continue the loop like

    if($key == ‘Download’ || $key == ‘Price’){continue;}

    first line in your foreach loop

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed