3.5 The Content Pages (Part 3)
This is the third part of the content pages.
1.Introduction1 lesson, 01:20
2.Framework Basics2 lessons, 14:38
3.PHP Files16 lessons, 2:08:48
4.Finishing Touches2 lessons, 23:07
5.Conclusion1 lesson, 01:31
3.5 The Content Pages (Part 3)
Welcome back. In the previous lesson, I finished the entry header for our post, and this is what we got so far. As you can see, the post meta is in place, the title is in place, and if we had any post thumbnails, they would also be displayed. So now lets move on to the entry content. Right here, I'm gonna say Article content. I'm gonna start with a div class .entry-content, and inside we gotta display the actual content. So, there are two cases here. If we have a normal page, then we display the content. If we have a search page, for example, I search for keyword, then I only need to display a small portion of the content, which is called an excerpt. So, I'm gonna do this if is_search. Then, I'm going to say the excerpt, else it's going to be content-- and this is a function that will display the actual page content, and we can send a parameter for a read more link. I'm going to mark that as translatable, continue reading, and I'm going to put a little arrow right there, and, alpha. Okay, so let's check it out. Refresh, and-- oh, we don't have any php here. My bad, sorry about this. php, and then close the php. Okay, refresh, and there it is. Testing has no content yet, but, "Hello world!" does. Now let's see--let's add some content here, this is some content, hit Update. Okay, cool, now, here's the thing. Some posts will be paginated, it means the content will be split up in multiple pages. So, we gotta make sure we add support for that. So under the content here, I'm gonna say wp_link_pages. This will display pagination links, if there are some. We don't have us any yet, but I'll show you what it does later on. And finally, let's do the article footer. I'm gonna use a footer tag with a class of, entry footer. And inside, we're gonna do something like this, ?php, and I'm gonna say, If we have a single page and the author bio exists, we display it. So author biography basically refers to the author description. So, for that we check like this. If, is single and the author biography can be checked by get the author meta description. Yeah, so if these conditions are true, let's do echo. Let's do an h2 followed by a translatable string, like "written by", and then the author, and then we close the H2. So, let's see. Testing. Let's see, if it's single and get the author meta description. Okay, so we don't have any description for the author. For that, let's go to Settings. Sorry, to users >> admin. And biography info, This is my bio. Okay, so once we update this, refresh. We're gonna see this: Written by admin. And we're gonna put here, get_the_author. Instead of the other because admin is printed twice. Okay, so now it's gone. So written by, get_the_author_name, and then under this, I'm just gonna put a simple paragraph, or echo paragraph, followed by the_author_meta, description. Okay. And, then close the paragraph, and then we have the biography. Our blog is starting to take shape. We have the blog index, here, the single page is displaying properly. And just so we can see that is working properly, let's add a few more posts. Now, to do that, you can actually grab a list of posts and pages built by the folks on WordPress. It's called Theme Unit Test. You can get it at this codex.wordpress.org/Theme_Unit_Test. And it's gonna give you a link here to an xml file, go ahead and download it to your computer. Once you do that, you need to go to tools, import. Hit on this WordPress button. It's going to give you a plugin information, WordPress importer. And also it gives us a warning that this plugin has not been tested with this current version of WordPress. But, that's fine. Go ahead and install it. And once it's installed, activate Plugin and run Importer. And, as you can see, it gives us some errors here. You can just ignore them for now. So, you can just choose File, and you can link to the XML file you just downloaded. Upload file and import. It's going to give you option to assign new usernames to the existing authors. Make sure you download and import file attachments, and hit submit. And once that's complete I can see that we have a bunch of posts that were added, and then a bunch of pages as well. So let's go ahead and refresh our main page, and as you can see, all of our posts are showing up, including images. Yeah, we can see the continue reading tag. You can see how it looks with multiple categories, with multiple tags, and let's click on one of these posts. Okay. There we go. Cool. So what about the other content file, that is present in index? 'content', 'none'. Well, let's go ahead and write that real quick. We can close this content php for now, so content none PHP. In here, I'm gonna start with a div with a class of "not found", and in here, I'm gonna say an H1 with a PHP, it's going to say "nothing found". Alpha, this is also a translatable string. And the main difference between underscore E and double underscore is that underscore E will always print the string right here, while double underscore will not. So, let's see what we got so far. We have the default content file, and then we have the content none file. All we got to do now is write the other content files for the post formats and that's coming up next.