WordPress.org

Ready to get started?Download WordPress

Forums

get_template_part Not Working (3 posts)

  1. GPixels
    Member
    Posted 2 years ago #

    I've been getting used to changing things from include Templatepath to get template part, but for the first time I am finding the get_template_part is not working but the include is. This is what I have for both where I tried one or the other:

    <?php include (TEMPLATEPATH . "/includes/customfields.php"); // get the custom field variables ?>
    <?php get_template_part( 'includes/customfields' ); ?>

    What I have is an include file: page-headers.php which used the include TEMPLATEPATH to get another file that contains only custom fields I created to add a page header with an image overlay title, caption, button, etc. But for the first time, I am discovering the TEMPLATEPATH works but if I change it to the get_template_part, it doesn't work. I also just directly added the custom field variables directly in this page-headers.php file and it worked too, but why would the get template part not work this time around?

    Thanks in advance.

  2. mrwweb
    Member
    Posted 2 years ago #

    get_template_part() and subdirectories don't always play that well together. See the relevant trac ticket.

  3. James Revillini
    Member
    Posted 2 years ago #

    <IGNORE>For me, it's not even bringing a resource from the same directory. In sidebar.php, I have <?php get_template_part('testimonial'); ?> and I have testimonial.php in the same directory as sidebar.php. I can make a change to sidebar.php and see it, so I know I'm editing the right file, and I can strip all logic out of testimonial.php and just put "TEST" in that file, and it still won't show. Error log shows nothing. Any thoughts? Things I could try? Oddly, in home.php, I have <?php get_template_part('home-content'); ?> and this pulls in content from home-content.php just dandy.</IGNORE>

    EDIT: I'm a dumbass. Spelling mistake.

Topic Closed

This topic has been closed to new replies.

About this Topic