Start learning with our library of video tutorials taught by experts. Get started

Dreamweaver and WordPress: Building Sites

Managing full posts


From:

Dreamweaver and WordPress: Building Sites

with Joseph Lowery

Video: Managing full posts

With its default settings, WordPress shows the most recent ten posts on the homepage. If you take a look at the archives link, you will see a listing of up to ten archives. The same thing is true of search results. While it's great to have a configurable setting, showing how many posts and archives and search results you can show, I think it's a little bit of a limitation that the same setting applies across the board. In this movie, we are going to look at how you can limit the number of posts displayed on the home page without affecting the rest of your site.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Dreamweaver and WordPress: Building Sites
1h 42m Intermediate Feb 24, 2012

Viewers: in countries Watching now:

In this course, author Joseph Lowery shows how to create a robust WordPress-based site using Dreamweaver. The course lays out the essentials of planning a site, explains how to implement custom sidebars, and demonstrates building page templates. The course also explains how to integrate PHP functionality and extend the WordPress database.

Topics include:
  • Understanding development environment requirements
  • Working with existing WordPress content
  • Handling standard pages
  • Managing full posts
  • Coding a basic template
  • Adding a custom sidebar
  • Working with WordPress functions
  • Inserting PHP code in posts
  • Including a recordset
  • Outputting data
  • Linking to dynamic pages
Subjects:
Web CMS
Software:
Dreamweaver WordPress
Author:
Joseph Lowery

Managing full posts

With its default settings, WordPress shows the most recent ten posts on the homepage. If you take a look at the archives link, you will see a listing of up to ten archives. The same thing is true of search results. While it's great to have a configurable setting, showing how many posts and archives and search results you can show, I think it's a little bit of a limitation that the same setting applies across the board. In this movie, we are going to look at how you can limit the number of posts displayed on the home page without affecting the rest of your site.

So I'm going to drill into my theme, tpa, and open up the index.php file, which is the main content area, switch to Code view, and I wanted to take just a moment to show you the PHP code that's responsible for outputting those posts. It starts here with the code block on line 4 and continues all the way down to line 23, the endif that you find there. This is known in WordPress speak as the loop. If there are posts, while there are posts, output the content that's found, in this case, in an article tag, including a link to title and an h2 tag, a div of meta content--basically the time it was published--the content itself, and then another div of post metadata, which show tags, categories, and comments.

By default, this loop will display as many posts, up to the number available defined in the WordPress settings. Let me show you where that is. So go to Settings > Reading, and here you'll see blog pages that show at most ten posts. So if we take a look at the site now, if I click on Visit Site, there is one post, there is two posts, and you have just two there. But let's go ahead and search for IP, and here's one, two, three. So it definitely shows more than two and if I had ten results for that, it will show those.

Now, let's look what happens if I change it to 1. Save Changes. Now let's go back to our site, and here we have just the one post on the homepage. That's great. But now, let's search for IP again, and we only have one search result returning. So the value that you set here is really a global setting. I'm going to restore it to 10 and then click Save Changes. Now, let's go back to Dreamweaver where we can put in a little bit of PHP code to limit your posts just on the homepage. And this code will go right after if (have_posts() ) on line 4.

I am going to open up another PHP code block, and put in the function query_posts(); and then within the parentheses, a pair of quotes, and we put in the property showposts= and then the number of posts that you want shown, in this case 1. Now let me close off the PHP function, save this. With the file saved, let's go back and take a look now.

In our site, we now have just the most recent posts, and in our search results, I will search for the same two-letter combination, and now we've got multiple results there. You will find that the query_posts function is very helpful. You can actually use it to limit your post to a specific category or tag, as well as the number. However, you should be aware that because it alters the main loop, it could affect the rest of your page.

To avoid these issues, use the wp_reset_query function after you're done. This code will go after the endif. Let me scroll up a little bit so you can see it better. Another code block, wp_reset_query, and then just an open and close parenthesis and a semicolon. Close the code block, and this page is done. So let me save it. Let's try it out in Dreamweaver.

I'll open up the index.php page from the site root, go into Design view and then Live view, and now I should have just the single post here on the homepage. It looks good. Let's try our search, and I'll enter in a value and then hold down the Ctrl key while I click Search. So I get the search results that follow that link, and here's our multiple search results. Okay. So we have successfully limited our index page to showing just the most recent posts while displaying multiple entries on other WordPress pages throughout the site.

Now that you've got a handle on managing full posts, you are ready to tackle partial posts, or excerpts.

There are currently no FAQs about Dreamweaver and WordPress: Building Sites.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dreamweaver and WordPress: Building Sites.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked