Viewers: in countries Watching now:
Now that you see how powerful these conditional statements can be in identifying just the first post on the index page only, or anything else, you can use these types of statements to create fully modular design. Meaning, you can use one piece here. For instance the content dot php template, to display specific content on specific pages, and create unique experience depending on where the visitor is currently looking at the content. As an example, you'll remember that when we look at single posts.
The single post starts off with a category list. But, if we look at an index right now, you can see that category list. Now, we have an option here where we can choose to add the category list into all index posts or just to specific ones. So, first, I'm going to go grab the code for the category lists. I'll go to contents single. And here, inside Entry Header, you find the category Call, you'll remember this is where we got the category list and then we display it if this is a categorized blog. So Ill copy this out.
And paste it in after my sticky post. And then if I want to I can choose to add additional conditional statements here. You'll remember we already have the conditional statement to test whether or not this is a categorized blog. And now I can add additional conditional statements to this section here to decide when I want to display the category list. For example, I can use this condition. Is front page, to only display the categories on the index pages. So, I'll save, this and you'll see on the index page here when I reload it, you'll see the category.
But if I go to uncategorize and look at the index for uncategorized, I don't see the categories any more. Or I can do the reverse. I can simply put a bang in front of it, and then it'll display no categories on the front page. But if I reload the category page, you'll see here we have the categories. But if I go to the home page, I have no categories. And then of course, if I want to revert back and want to display the categories on all pages, I simply go back and take away my condition. And now my categories display throughout the site.
This is modular design in action, and embracing this type of modular approach, will make it much easier for you to create fully custom experiences on all the different poles and pages within your theme.
There are currently no FAQs about WordPress: Building Themes from Scratch Using Underscores.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.