From the course: WordPress: Customizing Themes with Genesis
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Conditional statements
From the course: WordPress: Customizing Themes with Genesis
Conditional statements
- [Instructor] When you're working with functions.php, any code that you add will be applied across your entire site. So, what if you only want to add a bit of code in a particular instance. Say, maybe we don't want to display the post info on a certain category. Well, you can use WordPress conditional statements to make this happen. Let's try this out. So, going back to my site, we're on a category archive page for a category creatively named Category A, and here are the posts for that category and they all show this post info, and that's what I want to get rid of. The steps we need to take here are to unhook this bit of code with the remove action, and then write a custom function saying, show this unless we're on Category A. So, how do we do that? First, I'm going to use the Genesis Hook Guide to help me identify where this bit of post info is hooked. If I scroll down, and I see the hook immediately…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.