Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress Meta Data and Custom fields

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32697
    jlau
    Member

    Hi there,

    http://unit44.byethost33.com/clients/stoked/bashy/

    I’m building a website that has a database of clients. Each client has a image and a set of website links. At the moment I’m using custom fields to store the data and outputting them using the ‘get_post_meta’ function, with static HTML to state what the website is. For example:

    Website: blah.com
    Myspace: myspace.com/blah
    Facebook: facebook.com/blah

    This has worked fine, but now some of the clients do not have every kind of website, and I need to be able to delete the label that has no value. Or just put the ones that do have value.

    Any help would be kindly appreciated

    #76634
    TheDoc
    Member

    You should check to see if the custom field has any value first:

    
    $url = get_post_meta($post->ID, 'snippet-reference-URL', true);

    if ($url) {
    echo "

    Facebook: $url

    ";
    }
    ?>

    Something about that php looks wrong in the echo, but you get the idea!

    #76628
    jlau
    Member

    Sorry mate, my brain is a bit fried from doing this the last 8 hours solidly. Can you help me to structure it?

    This is my code i’ve been using without the if statement:


    Website: ID, $key, true); ?>">ID, $key, true); ?>
    #76620
    jlau
    Member

    Sorry for being dumb. I figured it out! xD

    #76621
    jlau
    Member

    Thanks a lot for the help! I was looking round the wordpress codex for ages

    #76622
    jlau
    Member

    Oh there was one other thing I’d like to do, which would actually probably have solve this problem too. On the clients page, i also have brands. and I want to be able to output both the key and the value dynamically. So the user can change it to something like:

    ea games website: http://eagames.com

    rather than having a generic name for each website

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.