WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
Custom Field condition (2 posts)

  1. triggeru571
    Member
    Posted 9 months 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.

    Thanks

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

  2. alanft
    Member
    Plugin Author

    Posted 9 months ago #

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

    http://codex.wordpress.org/Function_Reference/get_post_meta

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

    http://codex.wordpress.org/Function_Reference/get_post_custom_values

    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 ) )

Reply

You must log in to post.

About this Plugin

About this Topic