Quantcast
Channel: 916 Networks
Viewing all articles
Browse latest Browse all 63

Adding Page Attributes to Custom Post Types in WordPress

$
0
0

For some reason, the Page Attributes meta box is not available for Posts or Custom Post Types like it is for Pages.  Not exactly sure why that is, but I needed it for a Custom Post Type.

I researched and found only one solution, which worked great.

1.  Install the Custom Post Template Plugin (at your own risk! I didn’t write it).  Activate it.

2.  Add this to your functions.php file (assuming your custom_post_type is news and events):

function my_cpt_post_types( $post_types ) {
	$post_types[] = 'news';
        $post_types[] = 'events';
	return $post_types;
}
add_filter( 'cpt_post_types', 'my_cpt_post_types' );

3.  Create a template based off the single.php template.  Add this to the top. Save it in your WordPress theme folder.

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

4. Enjoy being able to use custom templates in your Posts and Custom Post Types!

post-template

The post Adding Page Attributes to Custom Post Types in WordPress appeared first on 916 Networks.


Viewing all articles
Browse latest Browse all 63

Latest Images

Trending Articles



Latest Images