wordpress custom post types : template location

Now let me explain why this makes intuitive sense.
(Prof. Larry Wasserman)

I wanted some hands-on with wordpress custom types and stumbled upon the usual quotes database, so one of my blogs has become a plugin quotes site with xml-rpc api. And ran into a minor geek problem : WordPress seems to want to pick mytheme/single-customtype.php or mytheme/single.php as template.

I don’t want to loose the custom template when I switch themes. So I added a standard redirect function using an array(‘slug’, ‘redirect-to-template’) in the blog options table.

First a function to register the redirect in the blog options table :

function customtypes_redirect_register($slug, $file, $overwrite=true)
{
    if(!get_option('customtypes_redirect')) {
	$redirects = array();
    } else {
	$redirects = (array) json_decode(get_option('customtypes_redirect'));
    }
    if(($overwrite===false)  && $redirects[$slug]) return;
    $redirects[$slug] = $file;
    update_option('customtypes_redirect', json_encode($redirects));
}

…then the actual redirect hooked into template_redirect :

add_action("template_redirect", 'customtypes_redirect');

function customtypes_redirect()
{
	if(!get_option('customtypes_redirect')) return;
        $slug_templates = (array) json_decode(get_option('customtypes_redirect'));

	global $wp;
	global $wp_query;
	global $post;

//if it aint a post or page, check if the post_type has a redirect, if the file exists, redirect and quit
	if (isset($wp->query_vars["post_type"]) && $wp->query_vars["post_type"] != 'post' && $wp->query_vars["post_type"] != 'page') :
		if(!$slug_templates[$wp->query_vars["post_type"]]) return;
		if(!file_exists($slug_templates[$wp->query_vars["post_type"]])) return;
                include($slug_templates[$wp->query_vars["post_type"]]);
	    	die();   		    
	endif;
}

Now I just have to register the redirect from the plugin file :

add_action('init', 'add_customtype_redirects');
function add_customtype_redirects() {
    customtypes_redirect_register('quote', ABSPATH . 'wp-content/plugins/'.basename( dirname( __FILE__ ) ) ."/my-customtype-template.php"); }

…and I can keep my templates in the plugin dir, and switch themes as much as I want.

Hell froze over and WordPress became a cms.

One of my pet peeves, I loathe building backend forms. Hell froze over and WordPress did what I want, and added the custom type post with a standard backend table handler. WordPress is become a CMS.

Why is the new custom types backend important ? It reduces risk and cost of ownership of small customizations to handle user tables, which makes WordPress more competitive in the small local business niche.

There is a sizeable market for small local business sites like the restaurant with their menu, for instance, the snackbar, the pizza delivery place, volunteer jobs. That is the market of 500 to 3000 bucks jobbing. Currently these have a choice between packages like Magento, Joomla, WordPress, Flash or the html-sixpager. Each have their own advantages and disadvantages, Joomla offer better user table support but have a smaller community, Flash looks better but has little standard installs, Magento offers a standard shopping cart and check-out but is aimed at online shops, and WordPress offers cheaper templates, better SEO, more pluggable functionality and a giant community but got stuck in being a publishing platform.

Once a company picked WordPress and wants to use small user tables, in case of a restaurant for an online menu or reservations, that requires custom coding and creates extra dependancies, cost and risk. If for every menu-plugin you have to write the table-handler with custom jquery, the average plugin costs 300 dollars (check the getafreelancer joblist ;) ). For a small business with a menu, agenda, reservations/stock, that is about 1000 dollars to handle maybe 200 records throughout the year. With updates that plugin can break and it takes time to find a developer that can fix it. The developer costs money, and losing turnover costs even more money.

With a standard user table manager within a year it costs 50 bucks to develop a solution (just Google ‘wordpress custom type restaurant menu’ and cut and paste it). Should the code break, a few hundred developers have the same problem at the same time, and it is fixed the same day with a free update.

Low risk and low cost in the development and ownership phase. That leaves in general more budget for layout and exploring exciting new possibilities for WordPress in the small business market.

Does a PDF file drain linkjuice ?

Is a pdf file an importance sink ? In backrub (the basic pagerank calculation) an importance sink is a page that is linked to but does not link back to the site itself and thus drains the ‘juice’ in the site, much like broken links.

Here’s an excerpt from Eric Enge interviewing Matt Cutts. In the entire interview Eric Enge focusses on linkjuice. When he mentions the PDF, Matt Cutts indicates he does not want to talk about pdf and pagerank. He does encourage us to prefer html versions over pdf’s.

Eric Enge: What about PDF files?

Matt Cutts: We absolutely do process PDF files. I am not going to talk about whether links in PDF files pass PageRank. But, a good way to think about PDFs is that they are kind of like Flash in that they aren’t a file format that’s inherent and native to the web, but they can be very useful. In the same way that we try to find useful content within a Flash file, we try to find the useful content within a PDF file. At the same time, users don’t always like being sent to a PDF. If you can make your content in a Web-Native format, such as pure HTML, that’s often a little more useful to users than just a pure PDF file.

Let’s look at Google Search : if you type inurl:.pdf in Google Search (something Pat Marcello also mentions on his seo news blog article on pdf links) you get a list with pdf-documents, for instance The Not So Short Introduction to LATEX2ε which has PR6 assigned.

pdf with pagerank in google

It shows PDF files are indexed (as Matt Cutts indicates), but more important, they have a pagerank. If so, the pdf document receives linkjuice. Experience of other seo’s shows GoogleBot does not follow or index links in pdf documents (V7N). If the links in the document are not indexed or followed, it does not pass on the linkjuice, it forms an importance sink and you loose linkjuice.

That makes me wonder how Google handled these PDF’s and how that affects the assignment of importance and indexing of the content.