From the course: WordPress: Building Child Themes

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Challenge: Conditional widgetized area

Challenge: Conditional widgetized area - WordPress Tutorial

From the course: WordPress: Building Child Themes

Start my 1-month free trial

Challenge: Conditional widgetized area

(upbeat music) - [Instructor] Earlier in this course, we completely removed the widgetized area. And even though I like the way it looks now that it's removed, it is a bit unusual to remove an entire branch of functionality from a theme. So what I want you to do now is conditionally add it back in, meaning, depending upon a condition, display the widgets on the front end. There are two main ways I'd look at solving this challenge: customize a template or write some PHP code. I actually tried both, and I strongly recommend customizing a template, since it's the most direct route. You'll also want to look through these conditional tags. These are a great starting place to know how to conditionally show content. What I want you to do is hide the widgetized area on regular pages and posts. But on pages that show a list of posts, like the blog page, go ahead and display the widgetized area. Good luck.

Contents