How to create 'if/then' code to show custom fields with CustomPress?

What code would I use to show the contents of a custom field if it has been filled in, but leave blank if it is blank.

For example, if I have a custom field for a url, have this:

Website: content of custom field

However, if the URL field is blank, not show anything at all.

  • Moonworks
    • Code Wrangler

    To be honest, I don't really know what I'm doign with that query code. My method of learning is to need something, then figure out how to do it.

    If you could give me a nudge in the right direction on how that works, maybe with a couple of good sites that speak in English, that would be great :o) probably solve many problems.

  • DavidM
    • DEV MAN’s Mascot

    Hi Joe,

    I don't believe you'd need any more than the installation instructions on this one actually. CustomPress provides an embed code for each custom field.

    What you'd need to do is copy that embed code where you want it in your theme's template file in order to put it to use. The code already includes the conditional for if the field is empty.

    Going further back though, you should have something like single-customposttype.php where you would paste the embed code in. Do you already have that file to work with for your custom post type?

    Cheers,
    David

  • Moonworks
    • Code Wrangler

    Ah right, I had it all confused in my numb brain.

    I was thinking that the embed code was to show things like category pages for taxonomies, and it just wouldn't change its mind.

    I'm going to go through the install page again and just check through everything, before askign anything else :0)

    Thanks.

  • DavidM
    • DEV MAN’s Mascot

    That's one of the things I love about Headway right there. It already provides you with the 'single' pages from within the Visual Editor and you can simply copy/paste the embed codes from CustomPress right into a HTML/PHP Leaf.

    More than that, you can drag and drop that leaf (or those leafs) where you want them in your layout.

    Cheers,
    David

  • Moonworks
    • Code Wrangler

    Thanks.

    Things have slowed down a bit on me trying new things for a little while, as I suddenly noticed the date and realised my main site is going live at a conference on July 2nd and I had a few things to do to it, such as create it :slight_smile:

    Like a certain Governor once said "I'll be back..."

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.