treehouse : what would you like to learn today?
Web Design Web Development iOS Development

WP query?

  • in WP, when I create content in a post -

    1) can I use the content from the post and display some information from it on the index.php page and some other information from the same content on a single.php page?

    I want to create a business directory theme and on the home page, show thumbnail pictures for each business, which when you click on one will take you to either the business' homepage or to a page that will display important information about the business along with a Google map showing where the business is (if the business does not have a web site).

    2) can I display an unlimited number of posts (i.e. thumbnail pictures) on the page?

    On the home page, the business' would be sorted in alphabetical order within categories (A-D, E-H, etc) and would be shown on the homepage within these groups. Since I don't know how many businesses would be shown on the homepage, can I overcome the posts per page limit specified in the dashboard?

    All of this is easier to do in HTML/CSS but I woud like to know if you can do something like this using WP.

    Al

  • All sounds totally doable to me!
  • need a few more details- I assume that I could execute the loop for each category (A-D, E-H, etc) for the total number of posts in any category, and to show different content for different pages (index.php vs single.php), I could use display:none; on elements depending on the page being displayed. is this correct thinking or am I way off base??

    Al
  • A little off.

    The single.php template should be set up to show one post. The loop will take care of that for you.

    On the home page you'll set up a few loops, each one looping through a specific category.