WordPress 3.1 vs 3.0 vs. 3.1.1 and “archives” URL’s

Updated on Apr 07, 2011 @ 02:54:

If you made the change below for 3.1RC-3.1 and/or used manually created tag/category links in 3.1RC-3.1 and just upgraded to 3.1.1, you may find that the links are broken. The reason is that in 3.1.1 the tag and category links returned to the 3.0 style with the word “archives” in the URL.

To make it work you can change .htaccess to the following:

RewriteEngine On
RewriteBase / #or where your blog root is

#RewriteRule archives/category/(.*) category/$1 [L,R=301]
#RewriteRule archives/tag/(.*) tag/$1 [L,R=301]
RewriteRule ^category/(.*) archives/category/$1 [L,R=301]
RewriteRule ^tag/(.*) archives/tag/$1 [L,R=301]

Posted on Feb 25, 2011 @ 00:22:

In WordPress 3.1 the link structure have been changed

Continue reading “WordPress 3.1 vs 3.0 vs. 3.1.1 and “archives” URL’s”

How to serve attachments from a free CDN (Coral)

You can use Coral free CDN to off-load the WordPress attachments (usually images). In order to use Coral you need to add “.nyud.net” to the site DNS address. For example, http://www.alekz.net will become http://www.alekz.net.nyud.net. Coral is usually too slow to serve all static content, so the most effective solution would be to use it only for the biggest files.

Here’s a simple solution. Add the following to functions.php of your current theme:

add_filter ('wp_get_attachment_url', 'freecdn_url');

function freecdn_url ($url)
    if (! is_attachment () ) return $url; 
    $cdn_url = ".nyud.net";
    $decomposed_url = explode ("/", $url);
    $decomposed_url[2] =  $decomposed_url[2] . $cdn_url;
    $url = implode("/", $decomposed_url);
    return $url;

Your theme (e.g. the bundled “TwentyTen”) must use wp_get_attachment_url(), of course. If not – you got the idea, didn’t you? ;-)

Also, you can use freecdn_url () function to rewrite any URL you want to download from Coral.

External searching in mybb

Sometimes you need to integrate web-pages with corresponding forum threads. Here’s one of the ways to do it.

$keywords=”MyBB integration”; // The search keywords
<!– The path to mybb search.php –>
<form method=”post” action=”http://www.yoursite.com/mybb/search.php”>
<input type=”hidden” name=”action” value=”do_search” />
<input type=”hidden” name=”keywords” value=”<?php echo $keywords; ?>” />
<!– search titles only –>
<input type=”hidden”  name=”postthread” value=”2″ />
<!– Search in all forums –>
<input type=”hidden” name=”forums[]” size=”15″ multiple=”multiple” value=”all”>
<!– All dates –>
<input type=”hidden” name=”postdate” value=”0″>
<input type=”hidden” name=”pddir” value=”1″ />
<input type=”hidden” name=”sortby” value=”lastpost”>
<input type=”hidden” name=”sortordr” value=”asc” />
<!– the result will be threads, not posts –>
<input type=”hidden” name=”showresults” value=”threads” />
<input type=”submit” class=”button” name=”submit” value=”Forum” />