WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
use custom field data with widget logic? (2 posts)

  1. progresst
    Member
    Posted 2 years ago #

    I am using the following code to dynamically display a city based on a custom field on a page. How do I configure this same functionality in widget logic? I see where I can configure a page and category but can I use custom field?

    <?php $value = get_post_meta($post->ID, 'locations', true);
    if($value == 'sarasota') {echo 'Sarasota';}
    elseif($value == 'bradenton') {
    echo 'Bradenton';
    } elseif($value == 'naples') {echo 'Naples';}
    else {echo 'Fort Myers';}
    ?>

    http://wordpress.org/extend/plugins/widget-logic/

  2. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    global $post; return is_single() && get_post_meta($post->ID, 'locations', true)=='naples';

    should show a widget for posts with 'naples' in the locations custom field.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic