Book Image

WordPress 3 Cookbook

By : Ric Shreves, Jean-Baptiste Jung
Book Image

WordPress 3 Cookbook

By: Ric Shreves, Jean-Baptiste Jung

Overview of this book

<p>Using the WordPress Content Management System, you can create a beautiful, dynamic, and amazing website. WordPress is a flexible and powerful tool that's ideal for creating both blog and non-blog websites. Are you feeling limited with WordPress, or are you wondering how popular blogs do a certain kind of thing that you can't?<br /><br /><i>WordPress 3 Cookbook</i> focuses on providing solutions to common WordPress problems so that you can translate your site to one of the best. 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 &ndash; from themes to widgets and from SEO to security. <br /><br />With this update to the WordPress 2.7 cookbook, you will learn many WordPress 3 secrets and techniques, with step-by-step, useful recipes dedicated to achieving a particular goal or solving a particular problem. <br /><br />You will learn to install and customize themes, work with plugins, customize content display, enhance interactivity with the user and build communities. Then, the book also teaches you to earn revenue through online sales and advertisements. You will also find recipes for SEO and enhancing usability, and the book finally winds up with information on the inevitable maintenance and security.<br /><br />This book helps you to get solutions to common WordPress problems, to make your site better, smarter, faster, and more secure.</p>
Table of Contents (16 chapters)
WordPress 3 Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Save time by using WordPress shortcodes


When you know that you'll have to insert the same code snippets on many posts, you should definitely create a shortcode. Introduced in WordPress 2.5, the shortcode API provides a simple set of functions for creating macro codes for use in post content. A classic shortcode looks like this:

[author_info]

Shortcodes can handle attributes. For example:

[download file="myfile.zip"]

Also, a shortcode can have embedded content:

[mycode]Some Content[/mycode]

In this recipe, we show you how you can create your own shortcodes and then use them in posts.

Getting ready

This recipe can be achieved with any WordPress theme. You don't need anything except your favorite WordPress theme and a text editor.

How to do it...

Creating shortcodes is relatively simple. For your first shortcode, let's create a simple one that will display a disclaimer.

We begin by adding a simp9le PHP function to your theme's functions.php file. To do so, follow these steps:

  1. Open for editing the functions...