The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

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

  1. progresst
    Posted 4 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';}


  2. alanft
    Plugin Author

    Posted 4 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