WordPress.org

Support

Support » Plugins and Hacks » Widget Logic » [Plugin: Widget Logic] Conditional for a Post in a Certain Category within a Custom Taxonomy

[Plugin: Widget Logic] Conditional for a Post in a Certain Category within a Custom Taxonomy

  • I need to display a widget on a single post for all posts that are organized into a particular category for a custom taxonomy.

    For example, how would I display a widget on for all posts organized into the “Dogs” taxonomy category of the “Animals” taxonomy?

Viewing 1 replies (of 1 total)
  • Alright, so apparently this need is not support with wordpress core functions. However, I found a great post on a related thread that provides the answer. ref

    Add this to your functions.php file:

    function is_city( $city ) {
        $cities = wp_get_object_terms( get_the_ID(), 'deals', array( 'fields' => 'names' )  );
    
        if( in_array( $city, $cities ) )
    	    return true;
    
        return false;
    }

    Add this to your widget’s “Widget logic” field:
    is_city(‘Orlando’)

    I have tested this, and it is working for me.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Widget Logic] Conditional for a Post in a Certain Category within a Custom Taxonomy’ is closed to new replies.
Skip to toolbar