Community Forums › Forums › Archived Forums › General Discussion › Custom Post Type not finding custom template
- This topic has 4 replies, 3 voices, and was last updated 11 years, 6 months ago by HammerHankinson.
-
AuthorPosts
-
April 16, 2013 at 11:49 am #35787HammerHankinsonMember
I'm not quite sure I'm going about this the right way but I'm trying to get my custom post type to display the default page template as opposed to the default blog template.
I've created a Client Directory content type named 'clients' with two taxonomies, State and Practice areas. By default it's displaying the content as a blog post with the blog sidebar and I'm trying to apply my custom client-directory.php template to the CPT so it doesn't look like a blog post but the code I'm using is returning an error.
Here is the code:
add_filter( 'template_include', 'clients_template' );
function clients_template() {
global $template;
if( is_post_type_archive( 'clients' ) || is_tax( 'state' ) || is_tax( 'practice areas' ) == get_post_type() )
$template_file = get_stylesheet_directory_uri() . '/client-directory.php';
return $template_file;
}And here is the message I get from using this filter:
"Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /wp-includes/template-loader.php on line 47"
Is there a better way to do this?
April 16, 2013 at 4:42 pm #35843blogjunkieParticipantAre you familiar with the Template Hierarchy? http://codex.wordpress.org/Template_Hierarchy
You could simply create a file in your child theme folder named archive-clients.php and put the code for the client directory in there. Remember to end with
genesis();
WordPress evangelist, Nike runner, Apple fanboy.
Work: ClickWP WordPress Support, Play: adventures of a blogjunkie. Talk to me on Twitter @blogjunkieApril 17, 2013 at 8:10 am #35941HammerHankinsonMemberHmm, this is interesting because I did try that with both archive-clients.php and single-clients.php files and the site doesn't recognize them which is why I was trying to use the template_include filter but that's not working either.
I am using the Custom Post Type UI plugin to create the CPT's, but I wouldn't think that would cause a conflict?
This is a site that I inherited from a developer that quit in the company I work for, I have no idea what he did but I seriously think he didn't set this site up properly or something because there is other genesis functionality that isn't working correctly.
April 17, 2013 at 5:19 pm #36023essaysnarkParticipantHere's what I did to modify how my CPTs are being displayed:
1) I copied the file single.php from the Genesis core directory, named it single-[cptname].php, and put it in my child theme directory.
2) To make it look more like a page than a post, I just removed the post_info stuff:// Remove the post info function remove_action( 'genesis_before_post_content', 'genesis_post_info' );
That's all I've got in the body of the file, and then the standard genesis(); at the bottom. If you want to change the layout so that it's got a different sidebar, you can use the Genesis filters.
Hope this helps get you pointed in the right direction!
April 18, 2013 at 7:52 am #36131HammerHankinsonMemberYes that does help actually. Thanks!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.