This topic has 4 replies, 2 voices, and was last updated 9 years by sealagency.

  • Author
  • #42236
     sealagency
    Participant

    Hello,

    For the blog section of my site, i created a special sidebar “blog”.

    On article pages and list item by category pages i would like to display the sidebar ‘blog’ instead of the sidebar by default.
    I had this problem for events (events +) fix by a function in function.php of sweetdate child. But I can not find the right conditions for blog pages.

    COPY CODE
    add_action('wp', 'set_sidebar', 10);
    function set_sidebar() {
    	global $_wp_sidebars_widgets;
    	//if( is_singular( 'incsub_event' ) ){  page event single
    	if( is_post_type_archive( 'incsub_event' ) || is_singular( 'incsub_event' ) || is_tax( 'eab_events_category' )) {
    		$_wp_sidebars_widgets['sidebar-1'] = $_wp_sidebars_widgets['sidebar-12'];
    	}
    }
    

    what to put in the place of:
    if( is_post_type_archive( 'incsub_event' ) || is_singular( 'incsub_event' ) || is_tax( 'eab_events_category' ))

    Thanks

    #43279
     Abe
    Keymaster

    Hi,
    if you want to check if you are on an article page then try
    if(is_single())

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #43320
     sealagency
    Participant

    Hello Abe,

    if( is_single()) || is_archive() || is_tax()){

    Ok, it’s work very well, the specific sidebar to articles (blog posts) is now displayed for the blog post, but this specific sidebare is displayed instead of the specific sidebar to events see the code of my first message.

    like i have events is_post_type_archive( ‘incsub_event’ ) || is_singular( ‘incsub_event’ ) || is_tax( ‘eab_events_category’ with ‘incsub_event’ and ‘eab_events_category’ for select only the events it’s necessary to have something that filters only the article of the blog for display the good sidebar.

    in summary:
    for events i want sidebar-12 instead sidebar-1
    for blog articles i want sidebar-13 instead sidenbar-1

    I hope you hundertand me …

    Thanks

    #43657
     Abe
    Keymaster

    You need to make your custom logic unfortunately of use a plugin like Content Aware sidebars

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #44220
     sealagency
    Participant

    Hello Abe,

    With Content Aware sidebars i can make what i want, it’s ok now!
    It’s a shame that we can not do it simply with code

    Thanks Abe!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘change sidebar on list category article’ is closed to new replies.

Log in with your credentials

Forgot your details?