Creating A Plugin Example

Now that you've seen the many different options WordPress provides for use in your plugins, you can put that knowledge to work In this example you will utilize many of the features covered in this chapter. At the end of this section the entire plugin source code will be available. The example plugin you are going to build is called Post Products. The goal of this plugin is to create an easy way to add product data to posts. This plugin will include the following features > settings page using...

Create a Menu and Submenus

WordPress features two different ways to create a custom menu for your plugin. The first thing you'll want to decide is where to locate your options page. The options page link can be located in its own top-level menu (My Plugin Settings), or as a submenu item of an existing menu (Settings O My Plugin Settings). This section explores both methods and how to configure each. The first method you'll explore is creating a new top-level menu. Using a top-level menu is useful if your plugin has...

Setting Up Advertising

Placing advertising on your site is no different than laying out a print page with a mix of editorial and commercial content Decide how many ads you want, where they are going to be placed, and what potential content conflicts you want to avoid. This is as much a design as a technical process, because you have to pay attention to the eventual page presentation and tone of the content when displayed with advertisements. Before running ads on your site, you need to create an account with one of...

BuiltIn Word Press Import Tools

For most WordPress users looking to transport content from one home to another, WordPress offers a variety of built-in import facilities. This section covers the basic conversion process and the use of WordPress eXtended RSS (WXR) files for more flexible or powerful data conversion. WordPress offers basic importers for commonly used blogging platforms. You can find these built-in importers on the Import dashboard in WordPress, and you'll find the corresponding PHP functions implementing them in...

Content Integration Via Feeds

In one situation we've encountered, we managed many sites, normally a subdomain for each department. In this example, each department functions as its own business unit. There are alternatives, but for various reasons each site became a unique WordPress installation. One of the challenges we then face is the duplication of content across multiple sites. Maintaining changes across these separate FIGURE 13-7 OpenID enabled WordPress login page FIGURE 13-7 OpenID enabled WordPress login page sites...

Advanced wpconfig Options

You can set additional advanced options in your wp-config file. These options are not in the wp-config file by default, so you will need to manually add them to the file. To set your WordPress address and blog address, use the following two options define('WP_SITEURL', 'http example.com wordpress') define('WP_HOME', 'http example.com wordpress') The wp_siteurl option allows you to temporarily change the WordPress site URL. This does not alter the database option value for siteurl, but instead...

Integrating Twitter

Even though we just used Twitter as an example of how to integrate any XML feed, let's look at how you could integrate Twitter specifically. Twitter is currently the poster child for open web service APIs. The Twitter API is well documented and easy to use. In addition, it has tons of features. All of this makes integrating your Twitter activities with your WordPress installation a breeze. As such, there are several things you can do with Twitter integration. For example, you can show your...

Create an Options Page

WordPress 2.7 introduced a new Settings API that you will be using for all of the option methods you use in this section. The Settings API is a powerful set of functions to help make saving options in WordPress easy and secure. One of the major benefits of the Settings API is that WordPress handles the security checks, meaning you don't need to include a nonce in your form. The first option page method you'll explore is creating a unique option page for your top-level menu. Remember that when...

Creating Custom Tables

WordPress contains a variety of tables in which to store your plugin data. However, you might find that your plugin needs a custom table or two to store plugin data. This can be useful for more complex plugins such as an e-commerce plugin which would need to store order history, product and inventory data, and other data that is accessed using database SQL semantics rather than the simple key and value pairing of the options table. The first step in creating a custom database table is to create...

Understanding The Loop

Understanding how the Loop functions will help you understand how you can control it. Controlling the Loop to display exactly the content you want will be one of your most used tools in developing WordPress-powered web sites. Because the Loop is at the heart of every WordPress theme, being able to customize the display content opens up the doors to making WordPress look and act however you want. To understand the Loop, it helps to break down the steps WordPress takes to generate a page's...

Moving Authors And Users

Most brochureware web sites are author agnostic. That is, you do not really have content attributed to specific site authors, because they are representing a business entity. You can continue with this method, even when using WordPress, which enforces authorship. All you need to do is turn off the author information in your theme. However, if you are moving from a site that has authorship ingrained, or this is something you want to implement on the new site, you will need to set up your authors...

Show Your Older Posts by Date Archivephp

Eventually, if you are diligent, your site will have older content. And if you are really industrious you will be able to do those fun one year ago on my site I told you about X'' posts. Eventually you may have copious amounts of content, and so much that it is not feasible or appealing to show it all on the front page. That is, if content is being generated on a regular schedule, there will come a point in time where you will want to refer to something that is clearly not going to be still on...

Word Press News Sites

Many different WordPress-related web sites exist. This section provides a list of the most popular WordPress-focused sites for news and information regarding anything and everything WordPress related. The WordPress Tavern is a web site focused on all things WordPress. This includes BuddyPress, bbPress, WordPress.com, and any project under the Automattic umbrella. The Tavern features a very active message board where members discuss the latest news and developments in the WordPress Community....

Theme218 Wordpress Shop

Action hooks, 127-132 Active Directory AD , 324-325 AD. See Active Directory additional hardware. See hardware, addition of admin accounts, 289-290 administrators, 34 WordPress role system, 296 advertising, of content, 242-247 monetization, 242-243 pay-per-click model, 243 pay-per-day model, 243 pay-per-view model, 243 setup, 243-247 conflict resolution, 246-247 editorial control, 244 manual placement, 245-246 plugins, 243-244 Akismet, 32-33 automated spam detection, 287 All Things D, 3 Allow...

Using Your Custom Taxonomy

Now that you've created your custom taxonomy you need to know how to use it on your web site. As always, WordPress features some very easy-to-use functions for working with your custom taxonomy. The following shows how you can display a tag cloud showing your custom taxonomy terms lt php wp_tag_cloud array 'taxonomy' gt 'ingredients', 'number' gt 5 gt The wp_tag_cloud function can accept a lot of different arguments, but in this example you're only using two taxonomy and number. First, you set...