Sillybean

Beginning WordPress 3 is here!

My book is out! I got my author’s copies over the weekend, and this morning a friend reported that her copy arrived in the mail. So, even though the official release date isn’t until Wednesday, it’s here!

It’s very strange to see the finished, bound book. I’ve been dealing with it as a series of Word files for months now. Even stranger: signing copies! I sent signed copies off to the winners of the LibraryThing and Goodreads giveaways.

The complete sample chapter, Working with Content, is now online. If you prefer, you can download it as a PDF. I’ve posted a few other bits and pieces; you’ll find them linked from the table of contents. I’ll post a few more over the next few weeks.

Since we had to send the book to the printers just as WordPress 3.0 was going into beta, there are a few updates and corrections. Let me know if you spot any others; I’ll keep that page up to date.

Go forth and order your copy! You can also get the ebook from the Apress website.

Feeds for custom content types in WordPress 3.0

As you’ve seen before, there are many feeds that aren’t publicized in WordPress. You can use a query string format similar to the one you used for searches to get feeds of your custom content types. The post_type parameter given should match the name of your custom content type. You can even combine content types. Here are some of the possible feed URLs for custom content types:

Feed Type

Default URL

Clean URL

RSS 2.0
(default)

/?feed=rss2&post_type=course /feed/?post_type=course
/feed/rss2/?post_type=course

Atom 1.0

/?feed=atom&post_type=course /feed/atom/?post_type=course

RSS 0.92

/?feed=rss&post_type=course /feed/rss/?post_type=course

RDF

/?feed=rdf&post_type=course /feed/rdf/?post_type=course

Combining content types

/?feed=rss2&post_type=course,post,page /feed/?post_type=course,post,page

Adding fields to existing options pages

There are lots of tutorials on adding a whole new options page for your plugin, but adding just a field or two to one of the standard options pages is a little different.

<br />
function add_extra_privacy_options() {<br />
     add_settings_field('extra_privacy', 'Extra Privacy Option', 'extra_privacy_options', 'privacy', $section = 'default', $args = array());<br />
     register_setting('privacy', 'extra_privacy');<br />
}</p>
<p>add_action('admin_init', 'add_extra_privacy_options');<br />
     // displays the options page content<br />
     function extra_privacy_options() { ?></p>
<input name='extra_privacy' value='<?php echo get_option('extra_privacy'); ?>' /><br />
<?php<br />
}<br />

The first argument in the register_setting() function is the one that identifies which existing page you want to use.

The new field on the Privacy settings page

That’s all you have to do! Just replace the form fields with your own. You’re using the Settings API, so your option will be saved and updated for you (as ‘extra_privacy’ in the wp_options table).

Publication delayed two weeks

Just got word from my editor last night: there’s a backlog at the printer, and as a result, my book will be out on the 30th rather than the 15th. Such is life!

[Tried to post this Friday evening from my phone. Apparently it got stuck as a draft. Argh.]

Excerpts from Beginning WordPress 3

I’m posting Chapter 4, Working with Content, in its entirety. So far the sections on Posts, Pages, and the differences between the two are up. I’m working on the Media Files section now, starting with Images and Galleries. Look for the sections on audio, video, and other files later this week.

I’m adding links to the Table of Contents as I go. (Other bits and pieces from the book are also linked there.) I’ll post a PDF of the whole chapter next week.