0

I am developing a website that requires specific pages to have certain elements change color in addition to a full-width calendar page. I figured that using page templates and changing what get_template_part looks for would be the simplest approach, but I've run into unexpected trouble. The page template loads fine, but the specific content template appears to get ignored, with WordPress instead loading the general template. I'm using a child theme derived from Twenty Fifteen, but this shouldn't be a problem, since the customized content template loads just fine.

get_template_part( 'content', 'page', 'kahvilaravintola' );

It should be loading content-page-kahvilaravintola.php, located right in the child theme's folder, but instead loads content-page.php, located in the same folder. I can't seem to figure out what is wrong.

  • I figured I was missing something relatively simple like that. I had actually tried just two parameters earlier, but it had not worked. I must have missed a typo somewhere. It is a bit suprising, but it is a good thing to keep in mind in the future. – Juho Kilpeläinen Oct 27 '15 at 22:25
1

Taken from the Codex and Dev Hubs:

 <?php get_template_part( $slug ); ?> 

 <?php get_template_part( $slug, $name ); ?>

get_template_part only takes 2 parameters, not 3. If you look in your error log you should be seeing warnings and notices that you passed a third parameter to a function that only takes 2. I would expect your call to load the file content-page.php then content.php. Nothing is done with kahvilaravintola, as it's an unexpected and unused third parameter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.