Book Image

WordPress 2.7 Cookbook

Book Image

WordPress 2.7 Cookbook

Overview of this book

About 120,000 blogs are created every day. Most of them quickly die, but a few stay, grow up, and then become well known and respected places on the Web. If you are seriously interested in being in the top league, you will need to learn all the tricks of the trade. WordPress 2.7 Cookbook focuses on providing solutions to common WordPress problems, to make sure that your blog will be one of the ones that stay. The author's experience with WordPress enables him to share insights on using WordPress effectively, in a clear and friendly way, giving practical hands-on solutions to WordPress problems, questions, and common tasks ñ from themes to widgets and from SEO to security. Are you feeling limited with WordPress, or are you wondering how popular blogs do a certain kind of thing that you can't? With this cookbook, you will learn many WordPress secrets and techniques, with step-by-step, useful recipes dedicated to achieving a particular goal or solve a particular problem. You'll learn the secret of expensive premium themes, how to optimize your blog for SEO and online profits, and how to supercharge WordPress with killer functions used by the most popular blogs over the Internet.
Table of Contents (17 chapters)
WordPress 2.7 Cookbook
Credits
About the Author
About the Reviewers
Preface
2
Finding and Installing Themes
Index

Using conditional tags to display content on specific pages


Sometimes, you may want to display some content only on specific pages or sections. For example, you may wish to display a welcome message on your blog homepage or show specific information on the Categories page. In this recipe, Let's learn how to do it with the help of WordPress conditional tags.

Getting ready

To achieve this recipe, you'll need a WordPress theme that you can edit.

How to do it...

  1. WordPress conditional tags are Boolean variables so you have to use them as a condition on a php if statement as shown in the following example:

    <?php if(is_page())
    {
        echo "Page title:";
        the_title;
    } ?>
  2. The preceding if statement will return false if the current page template isn't a WordPress page template so nothing would happen. Otherwise, the if statement will return true and will print the page title on screen.

  3. Conditional tags can be used in any theme files.

WordPress features a large amount of conditional tags for all needs...