meamusta
Member
Posted 2 years ago #
I'm modifying a theme to better suite my needs, but run into a mysterious problem. In my sidebar.php I have:
<?php
if (is_front_page() and dynamic_sidebar('Home Page')) { }
elseif (is_page() and dynamic_sidebar('Page Default')) { }
elseif (is_single() and dynamic_sidebar('Single Post')) { }
else { }
?>
But for some reason this does not work. WordPress does not even compile (if that is the correct term) my sidebar.php when it looks like that. But when I remove one of the lines beginning with "elseif" statements, sidebar.php compiles and theme works nicely (only missing the removed functionality).
Could someone please tell me what is wrong with my code.
This may not address your issue - but try replacing "and" with "||"
meamusta
Member
Posted 2 years ago #
It looks like it is the line
elseif (is_single() and dynamic_sidebar('Single Post')) { }
which is causing problems. Perhaps the "is_single()" function, because I tried to change the "Single Post" sidebar to another, but no luck. I'll continue debugging tomorrow.
meamusta
Member
Posted 2 years ago #
Replacing "and" with "||" would break the logic in the code. I want the sidebar 'Home Page' to be loaded to my front page, sidebar 'Page Default' to any other page and 'Single Post' when user browses to any single post.
If I replace "and"s with "||" sidebar 'Home Page' would be shown in any situation.
meamusta
Member
Posted 2 years ago #
Could be I misused the is_single() function here. I should use the is_post() instead. is_single need an argument also to check if a particular post is displayed, but I just need to find out if any post is displayed.
Perhaps what ws5f3dj7 meant was ´&&´ and not ´||´
MAC :)
novinar
Member
Posted 2 years ago #
novinar
Member
Posted 2 years ago #
http://www.leodata.de
The best of webdesign.