WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] if post_meta value = X (3 posts)

  1. eastbank
    Member
    Posted 3 years ago #

    Hello,
    I've been scouring for a method of doing this and have had no luck.

    I'd like to display an image conditionally based on what checkbox was selected when setting up a post. Here's what I've tried:

    <?php if ( get_post_meta($page->ID, "Color Sorts", true)==tan) { ?>

    and

    <?php if ( get_post_meta($page->ID, "Color Sorts", true)=='tan') { ?>

    But neither work...any help is greatly appriciated.

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try it with $post instead of $page (even if on a page):

    <?php if ( get_post_meta($post->ID, "Color Sorts", true)=='tan') { ?>
  3. eastbank
    Member
    Posted 3 years ago #

    Thanks, I got it to work using this:

    <?php if ( get_post_meta($post->ID, "Color Sorts", true)=='tan') : ?>

Topic Closed

This topic has been closed to new replies.

About this Topic