Custom Post Type not finding custom template

Community Forums Forums General Discussion Custom Post Type not finding custom template

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  HammerHankinson 2 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #35787


    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?



    Are you familiar with the 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


    WordPress evangelist, Nike runner, Apple fanboy.
    Work: ClickWP WordPress Support, Play: adventures of a blogjunkie. Talk to me on Twitter @blogjunkie



    Hmm, 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.



    Here’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!



    Yes that does help actually. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.