Support » Plugin: Widget Logic » [Plugin: Widget Logic] use custom field data with widget logic?

  • 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/

Viewing 1 replies (of 1 total)
  • Plugin Contributor alanft

    (@alanft)

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Widget Logic] use custom field data with widget logic?’ is closed to new replies.