Results 1 to 6 of 6

Thread: Display custom field only if value entered?

  1. #1
    Thread Starter
    Junior Member lcooper1784's Avatar
    Join Date
    Apr 2011
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Display custom field only if value entered?

    Hi all,

    So I've created a custom field on my site that allows users to create a keyword, or (as it's called on my site) a "pet code" that is displayed directly under the ad title. But this field is not required. I only want the field to display on the ad if the user has entered a value for it, and I'm having trouble getting that "if" condition working properly.

    Currently I have this in loop-ad_listing.php:

    PHP Code:
    <h3><a href="<?php the_permalink(); ?>"><?php if ( mb_strlenget_the_title() ) >= 75 ) echo mb_substrget_the_title(), 075 ).'...'; else the_title(); ?></a></h3><br />
                        <?php if ( get_post_meta$post->ID'cp_keyword'true ) ) ?><div class="petcode"><span><?php _e('Pet Code:''appthemes'?></span> <?php echo get_post_meta$post->ID'cp_keyword'true ); ?></div>
    What do I need to change to make that field show up only if they have created a pet code? I'm not a php expert by any stretch of the imagination, so I know I'm just missing something here...

    I know that if they don't enter a value then nothing will show up - I guess what I'm asking is how do I make it so that if they don't enter a value, the div.petcode won't display at all?

    Oh, and the url of my site is www.atascocitapets.org

    Thanks!

  2. #2
    Veteran demonlee's Avatar
    Join Date
    Mar 2011
    Location
    Antas, Spain
    Posts
    574
    Thanks
    6
    Thanked 51 Times in 46 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Demon- I shoot People
    www.demonlee.com Photography Website
    www.seemeadvert.co.uk Classipress Website
    www.imdb.me.com/demonlee Film

  3. #3
    Thread Starter
    Junior Member lcooper1784's Avatar
    Join Date
    Apr 2011
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    Veteran demonlee's Avatar
    Join Date
    Mar 2011
    Location
    Antas, Spain
    Posts
    574
    Thanks
    6
    Thanked 51 Times in 46 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Demon- I shoot People
    www.demonlee.com Photography Website
    www.seemeadvert.co.uk Classipress Website
    www.imdb.me.com/demonlee Film

  5. #5
    Thread Starter
    Junior Member lcooper1784's Avatar
    Join Date
    Apr 2011
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #6
    Member nickcollins's Avatar
    Join Date
    Mar 2012
    Location
    United Kingdom
    Posts
    88
    Thanks
    2
    Thanked 5 Times in 4 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. v3.0.4 Custom field display ordering
    By alinimmo in forum Report ClassiPress Bugs
    Replies: 4
    Last Post: May 11th, 2011, 04:54 PM
  2. Display custom field details
    By TheMannyMan in forum ClassiPress General Discussion
    Replies: 4
    Last Post: March 21st, 2011, 10:14 AM
  3. [HELP] Custom Field Display MOD, I want to display icons
    By teller in forum ClassiPress General Discussion
    Replies: 1
    Last Post: October 11th, 2010, 08:58 AM
  4. Custom Field Display
    By kwbridge in forum ClassiPress General Discussion
    Replies: 0
    Last Post: April 8th, 2010, 03:26 PM
  5. Custom Field Display
    By kwbridge in forum Help Using ClassiPress
    Replies: 0
    Last Post: December 31st, 1969, 06:00 PM