Change the Search-URL of WordPress

With WordPress it is easy to activate readable URLs. Only the search page is not affected by the setting yet, it comes with the syntax ?s as default. But there is a solution to change the URL as you wish.

The following example shows that even if you have permalinks activated, that the URL for the two searchterms wordpress and consulting looks like this: bueltge.de/?s=wordpress+consulting&submit=Search. With a little function, which communicates with the redirect, you can adjust the URL. In my case the URL with the two searchterms look like this with the following function: bueltge.de/search/wordpress+consulting.
Continue reading …

Set options on activation Themes

The Photo Blog Theme Greyfoto has been updated and I wanted to make sure that the settings of WordPress are as I need them for the theme. Therefore must be written some data in the database when activate. Currently there is no hook for this, as is known for Plugins. The discussion on WP-Hacker-List was just right on time, and possibly Theme Developers get these hooks, similar to Plugins in WordPress 2.9.

If you want to use the activation of the theme in order to set various settings, then the following snippet can be very useful, which came up in the discussion on the WP-Hacker-List. This works like a charm and should be useful for theme developers who want to enable the options upon activation.
Continue reading …

Themes and automatic_feed_links

Since WordPress 2.8, there is the function automatic_feed_links() in the function.php. Which writes the link elements for the RSS protocols in the header of the document. The advantage of this feature is, you do not need to worry about whether a change comes in the Feed-protocoll in a new version of WordPress, removed or a new one is added.


If we develop a theme for the general public, you have 2 options. You use automatic_feed_links() and the theme does not work with WordPress prior to version 2.8, or you do not use this function and write the links as before, in your header.php.

I also have a 3rd alternative ;).

if (function_exists('automatic_feed_links')) {
    automatic_feed_links();
} else {
    add_action('wp_head', 'wpe_feed_links', 2);
}

function wpe_feed_links() {
    echo '<link rel="alternate" type="application/rss+xml" title="'. get_bloginfo('name').' RSS Feed" href="'. get_bloginfo('rss2_url').'" />';
    echo '<link rel="alternate" type="application/atom+xml" title="'. get_bloginfo('name').' Atom Feed" href="'. get_bloginfo('atom_url').'" />';
    echo '<link rel="alternate" type="application/rss+xml" title="'. get_bloginfo('name').' '. __('The latest comments to all posts in RSS').'" href="'. get_bloginfo('comments_rss2_url').'" />';
}

First we look if the function automatic_feed_links() exists. If not (prior to WP 2.8), we use the hook wp_head and write the links in the header of the page. Thus we don't need to adjust the header.php anymore.