Sunday, 15 September 2013

wordpress - WP conditional statement for multiple categories -


My goal is:
especially on a tag / archive page: I would like To show a different sidebar for each category appearing on the page

What I have done now: I have three categories, 'Paintings', 'Photography' and 'Objects'. When a tag page is displayed, I want to see if there is a post from its 'painting' category and if so, then I would like to display it dynamic_sidebar drawing-sidebar. Photography - & gt; Photography- Sidebar and Object - & gt; Object_sidebar

This is part I have accomplished.

My problem comes when there are posts from multiple categories in any tag / store page, for example, posting from category 'paintings' and posting 'category' portfolio, in which case I have 'Paintings_ sidebar' And 'photography_sidebar' will be shown

As it is now, only sidebar is displayed for the category of recent posts in the sidebar.

What am I doing wrong? : (

Here is my small code:

  if (is_archive ()) {if (in_category ('paintings')) {dynamic_sidebar (' paintings-sidebar} (In_category ('photography'))} {dynamic_sidebar ('photography-sidebar');} if (in_category ('object')) {dynamic_sidebar ('object-sidebar');}    

{If_category ('Pictures')) {dynamic_sidebar ( ('Photography-sidebar');} Otherwise (in_category ('object')) {Dynamic_sidebar ('object-sidebar');} / Code>

No comments:

Post a Comment