Sidebar Help
-
It’s been so long since I haven’t coded in PHP and I’ve forgotten how to use IF statements. I’m creating a new WordPress theme and I’m working on my sidebar which has certain elements that have to be displayed of specific pages.
What I want to do is load the complete sidebar with all the elements in one file, depending on the page the user is on (e.g. About, Reviews, Headlines, Contact) I want certain parts on my sidebar to be displayed. I was thinking of using some IF statements; what I need to know is how to use them, let’s say the user is browsing the About page (about.php) and I want to display Box 1 on my side, the pseudo code would be:
if file = about.php
Display Box 1
End ifAlso, I’m planning on using .htaccess rewrite rules, so intead of seeing the about URL as https://www.mydomain.com/about.php it will be https://www.mydomain.com/about, by doing this would it affect the way PHP knows while file the user is currently looking at or does PHP know that the user is viewing about.php?
Additionally, let’s say Box 2 was only to be displayed on the homepage, what IF statement could I use for this? I also want to add an IF statement for certain categories (E.g. Reviews). If the user is looking at a post in the reviews section how would I go on about for displaying Box 3?
Thanks!
- The topic ‘Sidebar Help’ is closed to new replies.