WordPress.org

Ready to get started?Download WordPress

Forums

Removing custom field data from a page (2 posts)

  1. akiryk
    Member
    Posted 4 years ago #

    I'd like to let my client add a call-out quote to the home page — sometimes they will want it and sometimes they won't. I created a custom field called "call-out" where the client can add text. Then I put some php in my template like this:

    <?php  if(get_post_meta($post->ID, 'call-out', true)) { ?>
      <p class="call-out"><?php echo get_post_meta($post->ID, 'call-out', true); ?></p>
    <?php }; ?>

    What if they want not to have a call-out? If they delete the custom field, it's gone and they will need to create a new custom field in the future. Is there a better way?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Why not test to see if the custom field is populated?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.