Widget Logic
Custom Field condition (2 posts)

  1. triggeru571
    Posted 3 years ago #

    Hi Alanft,

    I was wondering how to use widget logic to NOT display the widget on Custom Post Types wich have a certain Custom Field selected (in my case if "featured" is selected.

    Right now, I have widget logic displaying the widget for custom post types as follows

    'is_singular('directory') || is_singular('directory-pages') || is_singular('restaurant-cafe') || get_post_meta('featured-label-directory', true)=='featured';`

    So, I would like to add the condition if Custom Field "Featured Label Directory" has "Featured" selected, then do not show the widget in the above custom post types.

    I tried to modify my code as you had sugested here http://wordpress.org/support/topic/plugin-widget-logic-use-custom-field-data-with-widget-logic?replies=2 but then my widget did not show up at all.



  2. alanft
    Plugin Author

    Posted 3 years ago #

    your syntax above with get_post_meta shouldn't work, as the first parameter should be the postID I thinkā€¦


    You could try using get_post_custom_values which uses the current post by default


    however you get it working you want your last condition to be about single posts where the meta doesn't match something

    A || B || C || (is_single() && !( your_meta_test_here ) )

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic