Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author oceanwp

    (@oceanwp)

    Thread Starter arnonalex

    (@arnonalex)

    Thanks a lot, working.
    And if I want to pin another side bar to another post type?
    That is to add a function code to pin another side bar to another type of post?

    Thread Starter arnonalex

    (@arnonalex)

    I tried this, but it doesn’t work.
    ————————————————————————————-
    function my_custom_sidebar_display( $sidebar ) {
    // Return a different sidebar for custom post type ‘projects’
    if ( is_singular( ‘projects’ ) ) {
    return ‘ocs-projects’;
    }
    // Return theme defined sidebar area
    else {
    return $sidebar;
    }
    // Return a different sidebar for custom post type ‘partners’
    if ( is_singular( ‘partners’ ) ) {
    return ‘ocs-partners’;
    }
    // Return theme defined sidebar area
    else {
    return $sidebar;
    }
    // Return a different sidebar for custom post type ‘days’
    if ( is_singular( ‘days’ ) ) {
    return ‘ocs-days’;
    }
    // Return theme defined sidebar area
    else {
    return $sidebar;
    }
    }
    add_filter( ‘ocean_get_sidebar’, ‘my_custom_sidebar_display’ );

    Plugin Author oceanwp

    (@oceanwp)

    Hello, you almost find ??

    Try this:

    function my_custom_sidebar_display( $sidebar ) {
    	if ( is_singular( ‘projects’ ) ) {
    		return ‘ocs-projects’;
    	} else if ( is_singular( ‘partners’ ) ) {
    		return ‘ocs-partners’;
    	} else if ( is_singular( ‘days’ ) ) {
    		return ‘ocs-days’;
    	} else {
    		return $sidebar;
    	}
    }
    add_filter( ‘ocean_get_sidebar’, ‘my_custom_sidebar_display’ );
    Thread Starter arnonalex

    (@arnonalex)

    Thanks a lot, working.

    Plugin Author oceanwp

    (@oceanwp)

    You are most welcome ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘associate a sidebar with a category’ is closed to new replies.