Forums

Custom template gets multiple header.php files (2 posts)

  1. shaunwallace
    Member
    Posted 8 months ago #

    I have a custom template page called "serve" and I call a custom header.php file with get_header('serve') within the template file and that works correctly but I also seem to be getting the default header.php file as well and I don't want that file included in the custom template page. Any suggestions? I am not calling get_header() anywhere other than in the index.php file but even if I remove that call, I still get the default header.php file included somehow.

  2. shaunwallace
    Member
    Posted 8 months ago #

    Edit to my last post. I think I found out where the problem is but would still like anyone's thoughts on how to fix it. I have a couple custom post types that that I get using WP_Query() on my home page and I also am setting up a new WP_Query object on the "serve" page as well so when I comment out the code that gets the custom post type data within the custom template, I don't have any problems but if I leave it, I end up getting calls to functions that are only called within the default header.php file. Is there a better way to get custom post type data and display that within the custom template files?

    Here's my code to get the post data and I am executing this within the header.php file and within the server-header.php file.

    $service_times = new WP_Query();
    $service_times->query( 'post_type=service_times' );
    
    //the loop
    while ( $service_times->have_posts() ) : $service_times->the_post();
        echo the_content();
    endwhile;
    
    // Reset Post Data to have Template Tags use the main query's current post again.
    wp_reset_postdata(); */

Reply

You must log in to post.

About this Topic