Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #5475
    ivoyages
    Participant

    Hi,

    I installed the plugin (on WordPress 4.0) and do a test but it does not work.

    Please find screenshot to understand what I mean.

    Settings
    The settings


    My widget’s code for all pages except those of “Afrique du Sud”


    My widget’s code for all pages of “Afrique du Sud”

    But if you go to this page of “Afrique du Sud” : http://www.i-voyages.net/jai-teste-le-restaurant-waterkloof-pres-de-stellenbosch/, you see the wrong widget

    Can you help ? Where is my error ?

    Greg

    #5479
    Bartosz
    Keymaster

    What kind of page is Afrique du Sud? Is this a page, post, custom post type, taxonomy term?

    #5482
    ivoyages
    Participant

    “Afrique du Sud”, it’s the name of the category (taxonomy). But I want to put the contextual sidebar in all articles of “Afrique du Sud”

    #5483
    Bartosz
    Keymaster

    Ok, can you confirm – you want to display a widget on every post that belongs to “Afrique du Sud” category? Am I correct?

    #5484
    ivoyages
    Participant

    Yes. Exactly

    #5485
    Bartosz
    Keymaster

    So you need to use a rw_display_widget filter hook here and WP conditional tags (http://codex.wordpress.org/Conditional_Tags).

    For example:

    function custom_rw_display_widget($display, $instance) {
    	// instance title is the widget title, in category can by category name, slug, ID or array of IDs
    	if ($instance['title'] == 'Partir en Voyage' && in_category('Afrique du Sud')) {
    		// display or hide the widget
    		$display = true; // or false
    	}
    	return $display;
    }
    add_filter('rw_display_widget', 'custom_rw_display_widget')
    #5486
    ivoyages
    Participant

    Ok. Thanks. I try it

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.