Notification of Posts Pending Review

WordPress does not send e-mail notifications to editors and administrators when a post is pending review the pending posts simply wait under Posts Edit until a reviewer logs in. If you do want e-mails of pending posts, install the Peter's Collaboration E-mails plugin. It allows you to add administrators to the general notification list, and it provides options to set up notifications for categories or groups of users, as shown in Figure 10-10. Figure 10-10. Peter's Collaboration E-mails options...

Viewing Scheduled Posts

Normally, posts scheduled for future publication are displayed in the same list as your other posts, under Posts Edit. When you have many future posts, this listing becomes unwieldy. The Editorial Calendar plugin allows you to visualize your scheduled posts. It places a new screen under the Posts menu (Figure 10-11) where you'll see a few weeks' worth of posts at a time. (You can configure the number in the Screen Options tab.) Move your cursor near the top or bottom of the calendar to scroll...

Dashboard and Settings

Once you've logged in and changed your password, it's time to go exploring. You've probably noticed the navigation menu along the left side of your screen. Did you notice that it has two formats By default, each menu option displays an icon and text (as shown in Figure 3-1), and you can click each option to expand the submenu below. Once you learn your way around, though, you might find that you recognize the icons alone and it's faster to hover over the main menu options to reach the submenus....

Dealing with Content from Microsoft Office

Even those who have been using WordPress for a while might have overlooked the handy Paste from Word button on the second row of the Visual editor's toolbar. If your Visual editor's toolbar has just one row of buttons, press the one labeled Show Hide Kitchen Sink. In the second row, you'll see a clipboard with the Word logo on it. Press this button, and you'll get a pop-up screen where you can paste the contents of your Word file (see Figure 4-4). It works well with Excel tables, too, and even...

Privacy

There are just two options under Privacy (Figure 3-13), and you've seen them before they appeared during the installation process, when you were asked if you wanted your blog to be visible to search engines. If you choose I would like to block search engines, but allow normal visitors, WordPress does the following Adds< meta name 'robots' content 'noindex,nofollow' > to your< head> content Responds to requests for a robots.txt file with one that disallows all user agents but only if a...

Permalinks

If you enabled permalinks in your Settings, you'll see a Permalink field on each post and page. The portion highlighted in yellow is derived from the title, with spaces replaced by dashes and other punctuation removed. This is called the slug. (Posts, pages, categories, and tags all have slugs.) If you don't like the generated slug or if it's too long, you can edit it using the Edit button to the right (Figure 410). Note that you can't edit the rest of the URL it's constructed based on the...

OEmbed

Embedding video from other sites is quite easy. As of version 2.9, WordPress supports the oEmbed standard. What this means is that you don't have to paste the complicated HTML provided by sites such as YouTube. Instead, you can simply paste the URL of the video page into your post as plain text. If you turned on the oEmbed options in your Media Settings, try it out now Grab a URL from YouTube, save your post (Figure 4-35), and view it. If everything is working as expected, your plain text URL...

Uploading an Image from Your Computer

The media uploader comes in two forms. By default, if you have Flash installed, you'll see the Flash-based uploader. This allows you to upload multiple files at once. However, if you don't have Flash installed, or if the Flash uploader doesn't work correctly, you can switch to the browser uploader. This gives you a basic Browse button that allows you to upload one file at a time. Using either version of the uploader, go ahead and choose an image to add to your post. Once WordPress has processed...

System Requirements

At minimum, your server should support MySQL version 4.0 or greater For clean URLs, a URL rewriting module that understands .htaccess directives, such as mod_rewrite on Apache or URL Rewrite on IIS 7 Your host should list these features and version numbers in the description of hosting plans or the support area (or both). Note that PHP 4 reached its end of life in 2008 and is no longer supported by its developers. While WordPress will run on these older...

Client Software

While you're waiting to hear back about your plugin submission, you need to install a Subversion client. Macs If you use a Mac running OS 10.5 or higher, the command line interface for Subversion is already installed, and you can use it via the Terminal. If you prefer a graphic interface, Versions by Sofa Software is an excellent client. You can also use Subversion through several code editors and IDEs. Textmate is one of the most popular. Windows and Linux You can download Subversion from...

Twitter Archive

As described by Doug Bowman it's possible to use WordPress to create a long-term archive of your Twitter account. The TwitterTools plugin has an option to create a new post from each of your tweets. If you're new to Twitter, just set up the plugin and let it run. If you have an existing Twitter account with a long history, you'll need to import your old tweets into WordPress somehow. Bowman recommends the service from tweetbackup.com. Another service, TweetScan, lets you export a CSV file,...

Roles in Action Notifications Moderation and Workflow

For administrators and editors, publishing posts and pages is simple write the content, press Publish. For authors, it's a little more complicated. Since they are not allowed to publish their own posts, they must submit them for review, as shown in Figure 10-7. Editors and administrators will then see the pending posts on the Posts Edit screen, as shown in Figure 10-8. They will not get an e-mail notification unless you add a plugin, as you'll see in the next section. Figure 10-7. Writing a...

Buddy Press

BuddyPress is a plugin with some associated themes that, when activated, turns your WordPress installation into a social network. Users can sign up, create profiles, and participate in discussions without ever entering the administration screens. BuddyPress is now available for single-site WordPress installations as well as networks, and includes all the same features except separate blogs for individual users. I'll demonstrate using the network installation. While BuddyPress can be installed...

Changing Contact Fields

The built-in contact fields are not always terribly useful. Business users need to add job titles, some social networks value Twitter usernames over instant messenger accounts, and so on. WordPress has a filter function that allows you to change the fields that appear in the Contact Info section. The code is fairly simple, as shown in Listing 10-3. Place it in your theme's functions.php file or in a new plugin (as you saw in in Chapter 9). Listing 10-3. Changing user profile contact fields...

Comment Moderation

The next three sections determine which comments are held for moderation. This means that they will not appear on your site as soon as the comment author submits them instead, they'll go into a queue in the administration area, and you'll have to approve them before they're published. You can require that all comments be held for moderation. This is not the default behavior, and for a typical blog, it would slow the pace of the discussion while inundating you with notification e-mails. A less...

Default Article Settings

You've probably noticed by now that posts and pages in WordPress are usually labeled as such, so the word article here is a tip that these settings apply to both posts and pages. These three options will be the default settings for any new posts or pages you write, but all of them can be changed on individual posts or pages if you need to deviate from the norm. If Attempt to notify any blogs linked to from the article is checked, WordPress will scan your post or page for links to other blogs....

Featured Images

The featured image (formerly known as the post thumbnail) is an image that represents your post. It might be shown by itself, or alongside the post content or excerpt, depending on how your theme displays posts. I talk about uploading images in the Media Files section of this chapter. Figure 4-15. Setting a featured image Figure 4-15. Setting a featured image If you don't see a Featured Image box on your Edit Posts screen (Figure 4-15), your theme probably doesn't support them. You can enable...

General

The General Settings are shown in Figure 3-6. You've already seen the first few options. The blog title and URLs shown here are the ones you chose during the installation process. The tagline is new this is a brief description of your site that might be displayed near your blog title, depending on the theme you choose. The Membership and Default Role options are useful if you want to start a group blog. If you allow visitors to sign up as users, you can allow them to contribute posts to your...

Media Files

WordPress allows you to upload virtually any kind of file and attach it to your post or page. You can add files using the uploader found on the individual post page editing screens and in the Media Library section. Files are stored in the location you specified on the Media Settings panel. WordPress offers specific upload dialogs for various file types. In order, the icons represent images, videos, audio files, and all other file types. While the upload interface looks more or less the same no...

Modifying Roles

If you need to change one or two capabilities, it's relatively easy to do so with a few lines of code in a plugin (see Chapter 9) or your theme functions (see Chapter 7). For example, if you want to allow any logged-in user to view your private posts and pages, you need to grant them two additional capabilities, as shown in Listing 10-6. This bit of code should go in your theme functions file or in a new plugin. Listing 10-6. Modifying an existing role allow subscribers to view private posts...

Roles

WordPress has five built-in user roles. Each has a set of capabilities (or permissions). They are Administrators can do anything in the WordPress administration area write, edit, and delete posts, pages, links, and comments upload media files of any type import content manage the Dashboard create, edit, and delete other users enable and configure plugins and themes change the site's theme and manage all the available options. Editors can publish, edit, and delete posts and pages written by any...

Securing Logins

In older versions of WordPress, the first user account was always named admin. This made it relatively easy for hackers to try to crack the password on the account. As of version 3.0, you can choose your username during the installation process. This cuts down on the scale of the problem, but it doesn't mitigate it entirely. You might still want to lock down your login screens. For even more security, you could force the login process to take place over SSL, thus encrypting your password...

Ssl

You have a few options when it comes to SSL. You can force WordPress to use SSL for logins only, or you can use SSL for all administration sessions. With the SSL login option, your username and password will be handled in a secure transaction. All your other traffic, including the authorization cookies you receive from WordPress, will be sent in the clear. With SSL-only admin sessions, your username, password, and all your authorization cookies will be encrypted. While this is obviously...

Summary

In this chapter, I've introduced you to WordPress. I've shown you how WordPress is easy for to install, easy to customize, and easy for you (and your content authors) to use. I've discussed the accolades WordPress has won, and I've shown you just a few examples of the wide variety of sites that can be built with WordPress. I've gone over the components of a basic WordPress site and explained some of the terminology (like template tags, sidebars, and widgets) you'll see often throughout this...

Theme Functions

This sample theme functions file includes many of the tricks shown throughout this book. Save it as functions.php in your theme directory, or copy the features you need into your existing theme functions file. Removing the meta generator tag (Chapter 11, Performance and Security) remove_action('wp_head', 'wp_generator') Changing excerpt length (Chapter 6, Basic Themes) function change_excerpt_length( length) return 100 add_filter('excerpt_length', 'change_excerpt_length') Changing excerpt more...

Upgrading the Network

To upgrade the sites on your network, first you must upgrade the main site. You can do this as you usually would, by going to Dashboard Update. Once the main site has been upgraded, go to Super Admin Update. Press the button there to upgrade all the network sites in turn, as shown in Figure 13-16. To upgrade network themes and plugins, simply update them as usual from the main network site (Dashboard Update). No further action is necessary.

Word Press Development Blog

This widget displays headlines from the blog at http wordpress.org development. New releases, including security updates, will be announced here. If you decide to configure this widget to use another feed, you should subscribe to the development blog feed (http wordpress.org development feed) in your RSS reader or sign up for email notifications at http wordpress.org download.

Nonhierarchical Postlike Content Types

Let's start transforming the courses by creating a new content type for a university. Listing 12-12 shows a simple plugin that creates a new nonhierarchical content type something very similar to posts. As with register_taxonomy(), you don't have to include arguments if you plan to use the default values. Listing 12-12. Creating a non-hierarchical content type for courses function post_type_courses() register_post_type( 'course', array( 'singular_name' > _( 'Course' ), 'public' > true,...

Importing from Word Presscom

To import content from a wordpress.com blog, first you need to export it. Log in to your wordpress.com account and go to the Dashboard of the site you want to move. Under the Tools menu, choose Export. If your blog has multiple authors, you'll have the option to export just one person's posts. You'll be prompted to save the XML file containing your posts, as shown in Figure 5-2. Figure 5-2. Exporting from wordpress.com Figure 5-2. Exporting from wordpress.com Once you have the XML file, log in...

Using Custom Taxonomies

If you publish the Harry Potter post shown in Figure 12-2, you can then browse to your archive page using the permalink structure you created and one of the terms you assigned. In this case, genre fantasy results in the archive page shown in Figure 12-7. Harry Folter anil llie Sorcerer's Stone Harry Folter and llie Chamber of Seems Harry Potter and the Prisoner of Ajinhan Harry Potter and the Goblet of Fire Harry Potter and the Order of the Phoenix Harry Potter and the Half Blood Prinac Harry...

About the Author

Stephanie Leary began designing websites out of boredom in high school. After earning a B.A. in English literature, she discovered that her skill with HTML had saved her from a career in the food services industry. In 2002, she became the web designer for the Texas A& M University Health Science Center, where she established accessibility and web standards. She also pioneered the use of blogs to manage press releases, columns, and newsletters. While at the HSC, she teamed up with web...

Mapping Domains

You can let your users map their own domains to their network sites using the Domain Mapping plugin This creates an options page under Tools Domain Mapping where users can enter the domain(s) they want to use. This feature might eventually be incorporated into WordPress itself, but was not included in 3.0. Once you have installed the plugin and enabled it for the network, go to Tools Domain Mapping. You'll be asked to copy a file, sunrise.php, from the plugin's folder to wp-content. You'll also...

Network Users

Under Super Admin Users, you may add more users to your network. They will be added to the site you selected in the Dashboard Settings section of your network options. Individual site administrators can then invite those users to become users of the subsite as well. They can also invite new users by creating a username and sending an email invitation. To add a user to a subsite, to to Dashboard My Sites and visit the subsite's Dashboard using the Backend link. Then to go Users Add New, where...

Categories

Categories can be a powerful tool for organizing your posts. Many magazine-style themes for WordPress rely on categories to break articles into divisions, much like a magazine's departments or a newspaper's sections. You can also get a feed for each of your categories (see the Feeds section of this chapter). By styling your categories differently and publicizing the otherwise hidden feeds for individual categories, you can create the illusion of multiple blogs for your visitors, even though...

Displaying a Users Information

To display a user's information inside the Loop, you don't need to find their user ID all the user functions will assume that you're talking about the current post author and fill in the ID automatically. You can use the the_author_meta() function to display user information. There's also get_the_author_meta(), which returns information for use in PHP rather than displaying it to the screen. Listing 10-2 shows how to create a footer for posts in a multi-author blog that displays the author's...

Dashboard Settings

When you add new users to the network without specifying a site for them, they will be added to the site you name here. This does not have to be your main site you can create another one to use as the holding area for new users if you prefer. New users may be added with any role, but the one you specify here will be the default choice. You may also specify an RSS feed to be displayed on all the network sites' Dashboards. If you plan to use your initial WordPress site as the news blog for the...

Writing

The first three options you'll see on the Writing Settings screen (Figure 3-7) have to do with the editor you'll see on the Post and Page Edit screens. WordPress uses the popular TinyMCE editor for its rich text option. The HTML view uses normal markup, but line breaks are converted automatically one becomes a < br > tag two denotes a break between paragraphs. In either view, the size of the post box is determined by the number of lines specified on this screen. The next two options...

Quick Edit

If you need to change the attributes of a post or page without editing the content, you can do so quickly using the Quick Edit feature. Go to Edit Posts (or Pages) and hover your mouse over the post you want to modify. A row of links will appear below the title Edit, Quick Edit, Delete, and View. Choose Quick Edit, and the table row will transform into a miniature editing form (Figure 4-28) that lets you change nearly everything about the page except the content, excerpt, and custom fields....

Sites Built with Word Press

These are just a few examples of WordPress sites. For more, visit the Showcase at www.wordpress.org. Many of the web's most famous designers have adopted WordPress Jeffrey Zeldman, Eric Meyer, Jason Santa Maria, Douglas Bowman, Dan Cederholm, and Aarron Walter are a few. Famous geeks Robert Scoble, Chris Pirillo, and Leo Laporte use WordPress, too. Celebrities using WordPress for their personal sites include Felicia Day, Kevin Smith, Stephen Fry, Martha Stewart, Emeril Lagasse, and Andy...

Other Comment Settings

The first three settings in this section are designed to help you eliminate unwanted comments. First, you'll have to decide how much information a commenter must provide. By default, they have to leave a name and an e-mail address. If you uncheck this option, only the commenter's IP address will be recorded. If you are planning a community site, you might choose to allow comments only from registered users. This option is not on by default, and it overrides the previous one. You can have...

Examining the Calendar Widget

Before I go into the details of custom widgets, let's take a look at the code for one of the simplest built-in widgets, the calendar (Figure 8-1). The code (from wp-includes default-widgets.php) is given in Listing 8-1. Things you would change in your own widget are in bold. Figure 8-1. The calendar widget in the widget manager area and the Twenty Ten theme Figure 8-1. The calendar widget in the widget manager area and the Twenty Ten theme Listing8-1. The built-in calendar widget class...

Word Press Tour

When you install WordPress for the first time (see Chapter 2), you'll have a simple site dressed in the lovely new 2010 default theme. (If this theme is not your cup of tea, don't worry. In Chapter 2, I'll show you how to install other themes, and in Chapters 6 and 7, I'll show you how to create your own.) Figure 1-7. A simple WordPress home page using the Twenty Ten default theme Figure 1-7. A simple WordPress home page using the Twenty Ten default theme Let's break down this page and see how...

Activating the Network

For existing MU sites, you can just upgrade. For single-site installations, you have to add a constant to the wp-config.php file define( 'WP_ALLOW_MULTISITE', true ) Save the file, and when you log back in to the Dashboard, you'll see that there is now a Network menu under Tools. Go to it, and you'll see the initial page of the network setup process, as shown in Figure 13-1. Figure 13-1. The network setup screen Figure 13-1. The network setup screen First, choose subdomains or subdirectories...

Dashboard Widgets and Users

Screen Options are personal settings that is, while you might turn off some Dashboard widgets, they'll still be visible to all other users. If you're managing a site for users who might be confused by the developer-specific information, particularly the Development Blog, the Plugins, and the Other WordPress News, you might want to turn off these widgets for all users. You can do so using the Clean WP Dashboard plugin (Figure 3-5). Figure 3-5. The Clean WP Dashboard plugin options Figure 3-5....

Creating the Options Form

In Listing 9-7, you saw the basic outline of the options page. Now you need to create the individual form fields that will allow users to change the plugin settings. First, you need to tell WordPress that this form will be using the option you registered earlier. You'll also go ahead and load the stored options into a variable so you can use them throughout the form. Listing 9-10 shows these changes to the basic form. Listing 9-10. Setting up options for use in the form displays the options...

Creating More Profile Fields

Because the code above works only on contact fields, you'll need to work a little harder to add fields elsewhere in the profile. In Listing 10-4, I've created a profile field for the user's birth year. You'll need to edit the code to reflect the field(s) you want to use. You can see the results in Figure 10-4. Listing 10-4. Adding user profile fields Plugin Name Stephanie's Extra User Profile Fields Plugin URI http sillybean.net Description Adds an extra field (the birth year) to the user...

[j[7g [j[J09pjm

Http www .youtube .com w cii v-ys Iz PF3 B fpQ Figure 4-35. Embedding a YouTube video is as easy as pasting the URL into your post. OEmbed works with a number of video providers. See codex.wordpress.org Embeds oEmbed for a complete list. This page also contains instructions on adding other video providers, if your favorite is not already included. Mr WeHPrna 1 Hille wuridt Figure 4-36. The YouTube video embedded from the URL

Moving a Word Press Site

If you ever need to move your WordPress installation from one server to another, start by reversing the installation process. Step 1 Download the WordPress files from your server. Make sure you have a complete copy of your wp-config.php and .htaccess files and your wp-content directory. Step 2 Export your database. If you have installed any plugins that create new tables, be sure to include them in your backup. They will share the prefix (e.g. 'wp_') you specified during the installation. You...

Using Widgets

Widgets offer a powerful way to change up your site without touching a line of code. WordPress comes with a baker's dozen of built-in widgets. You can download many more from the plugin repository, and some themes come with their own widgets. Figure 6-1 shows the basic widgets you'll find under Appearance Widgets. Figure 6-1. The widget management screen Figure 6-1. The widget management screen On the main page, you'll see a bank of available widgets. Below the available widgets, there's...

Reading

The Reading settings (Figure 3-8) determine how your posts appear to your visitors. This is where you can determine whether your site works like a blog, with the most recent posts on the home page, or displays something else. (There are more advanced ways of doing this, which I'll cover in Chapter 8.) If you select a page as your home page, you'll have the option to display your blog posts on another page. Anything you've entered into the body of that page will not be shown instead, it will be...

Displaying All Users Information

WordPress provides an archive template that displays all posts, but there is no template that displays a list of all users. Let's say that you are building a business site, and you want to take advantage of the new contact fields you defined above to display a user directory that will automatically reflect any changes your users make to their contact information. To do so, create a new page template containing the code shown in Listing 10-5. This code should be placed more or less where...

Creating Roles

Sometimes, rather than adding capabilities to an existing role, you need to create a whole new role. The code to do so is relatively easy. Again, place the lines in Listing 10-7 in your theme's functions.php file. add_role('privatereader', 'Private Reader', array( 'read' > 1, 'level_0' > 1, 'read_private_pages' > 1, 'read_private_posts' > 1, The add_role() function requires three arguments the role's name (for internal use), the display name, and an array of the role's capabilities....

Tags

If you're familiar with the concept of tagging from social media sites like Flickr, YouTube, or Delicious, the tag feature in WordPress holds no surprises for you. Tags are subject keywords, just like categories, but where categories must be set up ahead of time by an editor or administrator, authors are free to create new tags simply by typing them into the Tag box while writing a post (Figure 4-13). Note that after you've added new tags, you must press Add in order to apply them. Then, you...

Logging In

Welcome to the famous five minute WordPress installation process You may want to browse the ReadMe documentation at your leisure. Otherwise, just nil in the information below and you'll be on your way to using the most extendable and powerful personal publishing platform in the world. Please provide the following information. Don't worry, you can always change these settings later. A password will be automatically generated for you if you leave this field blank. Hint The password should be at...

Using Header and Background Images

If your theme supports custom header and background images, you'll see two additional menu items under Appearance. Let's start with backgrounds. Go to Appearance Background to get started. Figures 6-7 and 6-8 show the process of uploading a background image and setting the display options. Figure 6-7. Uploading a background image Figure 6-7. Uploading a background image Tttis will resnove tuckgrounO -mag*. You mil rwi h awe to retrieve any cimamlxwani. RwnOv* iikflround Figure 6-8. Setting the...

Plugin Recipes

Unless you're creating a simple blog, the key to creating a robust WordPress site is choosing the right combination of plugins to accomplish your goals. Here are a few recipes for turning a WordPress installation into something more. The combination of Sidebar Login, Front End Editor, and Posthaste will allow users to register, edit, and create new posts without ever seeing the WordPress administration screens. In order to let new users publish posts and edit posts written by others, you'll...

Discussion

The Discussion settings (Figure 3-9) allow you to control how your site handles comments and trackbacks whether comments and or trackbacks are allowed, how they're moderated, who's allowed to comment, how you get notified of new comments, and whether commenters' avatars are displayed. This is a dense screen with a lot of settings. I'll go through each section in detail. Figure 3-9. The Discussion Settings screen Figure 3-9. The Discussion Settings screen

Shortcodes

WordPress allows developers to define shortcodes bracketed words that are replaced with content when the post is displayed to visitors. Shortcodes work like text macros in Microsoft Word. WordPress itself uses shortcodes to insert some forms of media (photos with captions, image galleries). A typical image caption shortcode is shown in Figure 4-5, and the resulting image display (in the Twenty Ten theme) is shown in Figure 4-6. + Edil Pusl ' Tiisiiriy Trunk Wurd Testing Trunk Search angines...

Child Theme File Hierarchy

Child themes must include at least a style.css file. All other files are optional, even index.php. If a required file is not present in the child theme directory, WordPress will look for the file in the parent theme directory. In other words, you need to create files only when you want to override the parent theme's display. To demonstrate how child themes work, I'll go over my own theme, Cub Reporter, a child of the Journalist theme by Lucian E. Marin. The child theme's comment block requires...

Theme Checklist

The theme developer center at wordpress.org includes an extensive checklist If you prefer, there's an interactive checklist at where you can check off each item as you go and keep track of your progress, as shown in Figure 7-8. If you don't plan to distribute your theme to the public, don't sweat over each and every one of the 146 items on the checklist Just glance at it to make sure you haven't overlooked anything essential. As of this writing, neither checklist has been updated to include the...

Backing Up the Database and Files

Keeping regular backups of your database is essential if you want to be able to restore your site after something has gone wrong. Your hosting provider might do this for you, but it's still a good idea to keep your own copies in case something catastrophic happens. There are several plugins you can use to back up your database right from the WordPress administration screens. My favorite is WP-DB-Backup. Once you've installed it, you'll find a new Backup item under the Tools menu. On the...

Moving wpcontent

You can move your wp-content folder elsewhere if you like or rename it to something else. However, there are a number of constants related to the wp-content and plugins directories. To make sure your plugins continue working correctly, you should define all of these constants in your wp-config.php file. Add the constant definitions anywhere in the configuration file, as shown in Listing 11-4. Listing 11-4. Renaming wp-content to files define('WP_CONTENT_DIR', _SERVER 'DOCUMENT_ROOT' . ' files')...

Page Attributes Parents Templates and Order

You can arrange your pages into filesystem-like hierarchies by making them children of parent pages (Figure 4-19). In the Attributes box on any single page's Edit screen, you'll be able to select another existing page as the parent. That page could, in turn, have another parent, and so on. Figure 4-19. Pages arranged in a parent child hierarchy. Figure 4-19. Pages arranged in a parent child hierarchy. If you've turned on permalinks, your page's URL will be built by adding its slug to that of...

Complete Workflow

Even with Peter's Collaboration E-mails, the notification features are just not what they should be. For example, when an editor approves a post for publication, the author isn't notified The creators of the Edit Flow plugin aim to collect all of the missing role and notification features into a single plugin. Designed for newsrooms, Edit Flow includes custom post statuses (Figure 10-12), including Assigned, Pitch, and Waiting for Feedback editorial comments on the post editing screen and...

Galleries

If you have several images to add, you can do them all at once and insert them as a gallery rather than working with them one at a time. Instead of Insert into post, click Save all changes at the very bottom of the window. When you're finished uploading files, choose the Gallery tab. This is where WordPress groups all the photos that have been uploaded for this post. If you want to edit the title (or other details) of a photo, click Show (to the right). When you're done, you can insert all the...

Changing the Table Prefix

Since the default table prefix is well known, changing it is also a good step toward protecting your site from basic SQL injection attacks. If you installed WordPress with your host's one-click installer (like Fantastico), you might not have had a choice about the prefix otherwise, the prefix is an option you chose when you filled in your database username and password (Figure 2-5). Changing it after the fact requires you to modify the MySQL tables directly. How to accomplish this depends on...

Creating a Menu

To get started with your custom menu, go to Appearance Menus. Your first menu will be created for you when you load this page. Use the checkboxes on the right side of the page to add new items to your menu. You can add almost any kind of content as a menu item. By default, the menu management page shows pages, categories, and custom links to URLs you specify. However, in this page's screen options (Figure 6-3), you can turn on the boxes that will let you add posts, tags, custom content types,...

Adding a Section to an Existing Options Page

If you have just a few settings to work with and it would make sense to include them on an existing page rather than creating a whole new one, you can do so. For example, if you had an option related to privacy, you could use the code in Listing 9-29 to add your option to that page. Listing 9-29. Adding an option to the Privacy page function add_extra_privacy_options() add_settings_field('extra_privacy', 'Extra Privacy Option', 'extra_privacy_options', 'privacy', section 'default', args...

Importing HTML Files

I created the HTML Import plugin because the most common scenario, both in my day job and my freelance work, is moving a site from Dreamweaver templates into WordPress. I got very tired of copying and pasting The plugin works by reading in HTML as XML and copying the specified tags' contents into various WordPress fields. It therefore works best on well-formed HTML. Your files don't necessarily have to validate according to the W3C specification, but they should at least contain tags that are...

Editing Menu Items

To edit an item's details or delete it from the menu, use the arrow on the far right side of the item to show the detail editing box (Figure 6-4). By default, the menu item will display the title of the page or the name of the category. However, you can change both the label (the linked text) and the title attribute (the tooltip shown on hover). The original title will always be shown at the bottom of the menu item detail box, so you won't lose track of the item's source. In the screen options,...

Turning HTML into a Theme

WordPress theme files are basically HTML pages with some strategically placed, WordPress-specific PHP functions. While some PHP developers criticize the mingling of languages, preferring a strict separation of logic and layout, the WordPress system is flexible and easy to learn, once you figure out the Loop, which I'll go over in a bit. A theme is a collection of files in a directory, which will be stored in wp-content themes in the WordPress directory (unless you have changed this location in...

Comments and Trackbacks

In Chapter 3, you set your preferences regarding comments and trackbacks. Here, you can override those settings for the current post. If you're editing an existing post that has comments, you'll see the comments listed, and you can edit them right from this screen. iVPfV Wor-irrey, - .- I il.200B Wf& jSit -rg - rr i '- i'l.g p 3yitj news r.,iv< < 1 If you have converted categories to tags ano are now left with a lot of posts that have no category assigned (that stiow up with...

Changing Edit Screen Columns

Since you've added the college taxonomy to the course content type, it would be great if you could see the colleges on the Edit Courses screen. Adding columns to the edit screen is a two-step process first, define the column headers, and second, define the contents of the new column. The code to add a new column is fairly simple. Listing 12-15 shows how to add a column for the college taxonomy to the Edit Courses screen. Listing 12-15. Changing column headersfor the course content type * Custom...

Adding Your Own Scripts

When you need to add a JavaScript file to your theme, it's tempting to simply paste the < script> tag into header.php, dust off your hands, and move on to your next task. However, this is the wrong way to add scripts to a WordPress theme. You might recall from Chapter 3 that you can specify the location of the wp-content directory. If someone who has moved wp-content() tries to use this theme, the scripts will never load. Adding the < script> tags via the wp_head() action, as shown in...

Enabling Shortcodes in Text Widgets

As you saw in Chapter 4, shortcodes are bracketed placeholders you can use while editing your content that will be replaced with some other, more complicated content (like an embedded video or image gallery) when your post is displayed to visitors. Unfortunately, shortcodes are processed only in post page content. You can use them in text widgets, however, if you enable theme in the theme functions as shown in Listing 6-39. Listing 6-39. Enabling shortcode parsing in text widgets...

Custom Taxonomies for Custom Content Types

Let's say the department in question is the Honors office. This office tracks the Honors courses offered in each college. Before custom content types came along, they would use categories for each college, but those categories were mixed in with the general blog categories (news, scholarships) and the office's podcast. You can instead use a custom taxonomy for your colleges. Once you've created the taxonomies, you have to register them for the course content type. Listing 12-14 shows the...

Custom Fields

Custom fields allow you to create new attributes for your posts and pages. Some common uses for custom fields include adding a mood to each blog post, providing custom CSS for posts or pages, listing what music you're currently listening to or the books you're reading, or setting an expiration date for posts. Many themes and plugins have been built around the idea of using custom fields to store an image to represent each post, but as of WordPress 2.9, that can be accomplished using the field...

Creating the Custom Fields

First, you have to modify your post type function to add a callback. This is the name of the function that will add (and or remove) custom meta boxes from the Edit screen. Listing 12-21 shows the change. Listing 12-21. Updating the post_type_courses() function to include callback argument function post_type_courses() register_post_type( 'course', array( 'singular_name' > _( 'Course' ), 'description' > _('Individual course data'), 'public' > true, 'show_ui' > true, 'register_meta_box_cb'...

Caching and Mobile Stylesheets

The final checkbox in the main set of Super Cache options turns on mobile support. This doesn't mean much unless you're also running a second plugin that provides a mobile version of your site. To demonstrate how this works, I'll walk you through setting up Super Cache to work with WPTouch, the plugin that provides mobile versions of all sites on wordpress.com. The WPTouch settings screen has a multitude of options. I won't discuss them all here the ones I'm interested in showing you are in the...

Using Categories and Tags as Keywords

If you need to add meta keywords to your single post archive template, you have all the data you need your categories and tags. All you have to do is get a combined list, separated by commas. In this example, you first use a conditional tag to make sure this code is used only on single post archives. (Pages don't have categories or tags, and the get_the_tags() and get_the_category() functions won't work correctly on archive pages containing multiple posts.) Then, for each tag and category, you...

Including Custom Content Types in Your Theme

To create a single archive page for a custom content type, all you have to do is create another file in your theme directory, single-type.php. However, there is no built-in way to create a dedicated archive for a custom content type. To work around this, you must use a page template. Listing 12-18 shows an example archive template for Twenty Ten. Save this to your theme directory, then create a new page called Course Archives and choose this file as its page template (Figure 12-20). Listing...

Installing Plugins

While WordPress includes most of the features you would want in a basic site, sooner or later you'll probably find that you want something more. Visit www.wordpress.org extend plugins to see all the things-over 9,000 -you can add to your site. You can download the plugin files and upload them to your wp-content plugins folder, just as you did with themes. However, there is also an automatic plugin installer. From your Dashboard, visit Plugins Add New. On this screen (Figure 2-15), you can...

Page Lists and Page Menus

The wp_list_pages function supports several parameters that allow you to change the way pages are listed. By default, all pages will be listed in alphabetical order. Listing 6-27 shows several alternatives. See for the full list of available parameters and their default settings. Listing 6-27. Using the wp_list_pages function lt -- all pages in alphabetical order -- gt lt ul gt lt php wp_list_pages gt lt ul gt lt -- all pages in menu order -- gt lt ul gt lt php gt lt ul gt lt -- to exclude a...

Adding the Gettext Domain

At this point, if you haven't already signed up for your Subversion repository, go ahead and do so. You won't have access to the automated tools until you've checked in the first copy of your plugin. If you don't want the plugin to be available to the public until the translation features are done, give the plugin file header a lower version number than the stable version listed in the readme file. Once you've checked in the first copy of your plugin, log in to Extend and visit your plugin's...

Advanced Link Attributes

The image address Figure 4-40 is the URL of any image you want to represent your link. You could use something small, like a favicon that could be displayed next to the link text in a typical blogroll list. At the other extreme, you could choose a large image, and customize your theme so that the images are shown and the titles appear only as alt or title attributes. Using this technique, you could turn your link manager into an image gallery and, by adding a little Javascript into the mix, you...

Tracking Down Performance Problems

If your site is slow, but it's not because of an inefficient permalink structure, tracking down the cause can be bewildering. What are some things that would cause performance problems Plugins that write a lot of records to the database, like Audit Trail, or anything that says it will slow things down, like the Super Cache option to clear the cache every time a post or page is saved. There are several tools you can use to identify the problem. First, you should make sure it's not just a...

Listing Attached Files

You can display all the attached files of a post without going to the trouble of inserting each one into the post content. The required code looks very much like a second Loop, as shown in Listing 7-6. This could be placed inside the main Loop, perhaps just after the_content . Listing 7-6. Listing a post's attached files inside the Loop attachments get_children array 'post_type' gt 'attachment', 'numberposts' gt -1, 'post_status' gt null, 'post_parent' gt post- gt ID lt ul class attachments gt...

Login Lockdown

The Login Lockdown plugin helps protect you from brute force password attacks by disabling the login function for a range of IP addresses alter several failed attempts in a short period of time, as shown in Figure 11-10. Using the default settings, it will lock you out for an hour after you've failed to enter the right password three times in five minutes. If you're the sort of person who continually forgets your password, this might not be the plugin for you However, since guessing at...

Loop for Each Category

Now that you've reset your query, it's time to create that magazine layout. There are various ways to accomplish this, depending on how you've set up your content. Perhaps you've created a hierarchy of pages, and you want to show those instead. For the moment, however, let's assume that you're using categories to segregate your posts into different departments, since this is the most common scenario. Once you see how this works, you should be able to adapt this code to your needs using some of...

Setting up Super Cache

Unlike most plugins, Super Cache doesn't start working as soon as you activate it. You have to configure it first. You'll see a red-outlined warning message on your plugin list until you set up caching or deactivate the plugin, as shown in Figure 11-2. Figure 11-2. WP Super Cache activation Figure 11-2. WP Super Cache activation Go to Settings Super Cache to configure the plugin Figure 11-3 . The first thing you have to decide is whether to run the plugin in Half On or full On mode. In Half On...

Making Room for Options

For a more complex example, let's look at the Next Page plugin, which provides three template tags. They print links to the previous, next, and parent pages of the currently viewed page. The corresponding functions are very similar to one another, but I'll show you all three so you can see the minor differences. There's a fourth function as well, a utility that's called by the previous_link and next_link functions. It gets a list of all pages, minus those explicitly excluded, and returns them...

Adding an Options Page

Almost every WordPress plugin involves some sort of option, and that means you'll need to create the form that lets users manage those options. If you went through the process of creating theme functions back in Chapter 7, the process for plugins will look very much the same. To add an options page to the main navigation menu, you need two functions. One will display the content of the options page, and the other is a container for the add_options_page function. Finally, you'll need to add your...

The Shortcode API

Creating shortcodes in WordPress is a matter of creating the function that prints out what you want, and then defining it as a shortcode. In the case of Next Page, the shortcodes are just alternatives to the template tags they do the same thing. Since that's the case, and there are no arguments to be dealt with, creating the shortcodes takes all of three lines, as shown in Listing 9-17. Listing 9-17. Creating the three Next Page shortcodes add_shortcode 'previous', 'previous_link' add_shortcode...

Why Word Press

WordPress is one of many PHP MySQL content management systems that allow content editors to use a web interface to maintain their sites instead of editing and uploading HTML files to a server. Some systems, like Movable Type and Textpattern, have reputations as good blogging platforms. Others such as Joomla, Drupal, and Expression Engine are more commonly associated with commercial or community sites. WordPress began as a blogging tool, but early on the developers added pages as a separate...