• Resolved justawebbie

    (@justawebbie)


    I am new to WP but giving it a try on making my own child theme from Twenty Thirteen. I am trying to get a different sidebar for category, tag, and page. It does not work for the news category. I have this code in my footer, should i put it somehow in my functions.php? If so, would someone explain how to do that to me. Can you tell me what I did wrong please.

    <?php if (is_home ()) {
    		get_sidebar( 'main' );
    	} elseif (is_category('events')) {
    	        get_sidebar('events');
            } elseif (is_category('news')) {
    		if (has_tag('employee')) {
    			get_sidebar('employees');
    		} elseif (has_tag('student')) {
    			get_sidebar('students');
    		} else {
                            get_sidebar('news');
                    }
             } elseif (is_page('Athletics')) {
    		get_sidebar('athletics');
             }else {
                    get_sidebar();
             } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • It does not work for the news category.

    what happens?
    no sidebar at all?
    the wrong sidebar respective to the tags?
    ??

    Thread Starter justawebbie

    (@justawebbie)

    Oh I am sorry forgot to put the important part. No sidebar shows up at all for either news or employees or students. It shows up for the home page. I am headed to check to see if it shows up for athletics now.

    Thread Starter justawebbie

    (@justawebbie)

    Shows up for athletics as well. To get it to show up for events I changed it to say (is_singular(‘events’)) since i realized it was not showing because it was a custom post type. So what is not working is the News section of the code.

    Thread Starter justawebbie

    (@justawebbie)

    I was able to get it all working finally. Just kept reading and searching and trying everything I found. I hope this helps someone else new to wordpress with conditional tags.

    <?php if (is_home ()) {
                    get_sidebar( 'main' );
               } elseif (is_singular('events')) {
                    get_sidebar('events');
               } elseif (in_category('news')) {
                    if (has_tag('employees')) {
                            get_sidebar('employees');
                     } elseif (has_tag('students')) {
                             get_sidebar('students');
                     } else {
                             get_sidebar('news');
                     }
             } elseif (is_page('Athletics')) {
                     get_sidebar('athletics');
             } elseif (is_post_type_archive('events')) {
                     get_sidebar('events');
             } else {
                     get_sidebar();
             } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘getting different sidebars in footer’ is closed to new replies.