Custom Content Type Manager
[resolved] Conditional statement (5 posts)

  1. ataxel
    Posted 2 years ago #

    I there, I really enjoy to get to know your plugin. I can now built more personal website and that is so great.

    As for now, i'm working on template and have some questions. For the moment, i'll only ask about not displaying an empty custom field. I mean if the custom field is empty, i won't print any label either.

    As for my small knowledge, it works with :

    <?php if($custom_field_name !== '') { ?>
    LABEL: <?php echo $custom_field_name; ?>
    <?php } ?

    Can you help me manage this part please.
    By the way, i read the 7 pages of topics here to find solution...

    Namaste, Lp(*


  2. 416BC
    Posted 2 years ago #

    This works for me.

    $city = get_custom_field('location_city');
    if ($city !== ''): ?>
    	<strong>Location: City</strong> <?php echo $city; ?>
    <?php endif ?>
  3. 416BC
    Posted 2 years ago #

    Here is a bit shorter and cleaner.

    if ((get_custom_field('location_city')) !== ''): ?>
         <strong>Location: City</strong> <?php print_custom_field('location_city'); ?><br />
    <?php endif ?>
  4. ataxel
    Posted 2 years ago #

    Thank you, it's really appreciate!

  5. 416BC
    Posted 2 years ago #

    Glad I could help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Content Type Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic