I have a custom post type with some metaboxes, for this CPT have his own single-CPT.php where I show his content and metaboxes and url domain.com/CPT. But what I need to know is if posible to create a second template where I only show the metaboxes content of this CPT and url domain.com/CPT/metaboxes

Hope it make sence and have a solution :P

Thanx to all.

  • Are you talking about like when you can select a template like you do in a drop down for page templates? For example: One post type with more than one template to choose from. Or just a default template that only this custom post type is going to be using?
    – Nicole
    Dec 14, 2011 at 16:37

1 Answer 1


Yes it is possible. You'll have to write a custom rewrite rule for making the domain.com/cpt/metaboxes url to be accessible. Lets say your cpt is 'movie', its single will be accessible as domain.com/movie/slug. Create a new page named 'Metaboxes' (slug should be 'metaboxes'). Add the following code to functions.php.

add_action('init', 'add_my_rule');

function add_my_rule()
    global $wp_rewrite, $wp;
    $wp_rewrite->add_rule('^movie/([^/]+)/metaboxes', 'index.php?pagename=metaboxes&movie_slug=$matches[1]', 'top');

After you add this code, go to Settings > Permalinks and just hit save (don't miss this step!). Make sure you have pretty permalinks turned on.

Next step is to access the movie_slug on this page. Create a template which will show the metaboxes content and assign this template to the Metaboxes page created above. Add the following code to this template:

 * Template Name: Metaboxes

//this will give you the cpt slug.
$slug = get_query_var('movie_slug');

//now we get the cpt object using the slug
    'name' => $slug,
    'post_type' => 'movie',
    'post_status' => 'publish',
    'showposts' => 1,
    'caller_get_posts'=> 1

$movie = get_posts($args);

//we need only the ID
$movie_id = $movie[0]->ID;

//Use the $movie_id to get all the metaboxes content, means the post meta/custom values and build your markup around it.

I haven't tried this, but I'm sure it will work with a minor tweaks. Let me know if you are stuck or face any errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.