Custom Post Template – WordPress plugin Free download

Click to Download

Custom Post Template

Description

Provides a drop-down to select different templates for posts from the post edit screen. The templates are defined similarly to page templates, and will replace single.php for the specified post. This plugin will NOT switch the templates for the different posts in a listing page, e.g. a date or category archive, it will only affect the template used for single posts (i.e. you can choose a template which is not single.php).

Post templates, as far as this plugin is concerned, are configured similarly to page templates in that they have a particular style of PHP comment at the top of them. Each post template must contain the following, or similar, at the top:

<?php
/*
Template Name Posts: Snarfer
*/
?>

First note: Page templates use “Template Name:“, whereas post templates use “Template Name Posts:“.

Second note: You must have the custom post template files in your theme in the same directory/folder as your index.php template file, not in a sub-directory/sub-folder.

Developers

If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here’s an example below of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types. This code can be added to a plugin or to the functions.php file in your theme.

/**
 * Hooks the WP cpt_post_types filter 
 *
 * @param array $post_types An array of post type names that the templates be used by
 * @return array The array of post type names that the templates be used by
 **/
function my_cpt_post_types( $post_types ) {
    $post_types[] = 'movie';
    $post_types[] = 'actor';
    return $post_types;
}
add_filter( 'cpt_post_types', 'my_cpt_post_types' );

Installation

The plugin is simple to install:

Click to Download the plugin, it will arrive as a zip file
Unzip it
Upload custom-post-template directory to your WordPress Plugin directory
Go to the plugin management page and enable the plugin
Upload your post template files (see the Description for details on configuring these), and choose them through the new menu
Give yourself a pat on the back

FAQ

Installation Instructions

The plugin is simple to install:

Click to Download the plugin, it will arrive as a zip file
Unzip it
Upload custom-post-template directory to your WordPress Plugin directory
Go to the plugin management page and enable the plugin
Upload your post template files (see the Description for details on configuring these), and choose them through the new menu
Give yourself a pat on the back

I get an error like this: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /web/wp-content/plugins/custom-post-template/custom-post-templates.php

This is because your server is running PHP4. Please see “Other Notes > PHP4” for more information.

Reviews

Leave a Reply

Your email address will not be published. Required fields are marked *