1

I want to display different content on my home page and in single pages, so I am using the following code in index.php:

get_template_part( 'template-parts/content-home', get_post_format() );

At first I am displaying content-home.php, then I will create new templates like content-home-video.php etc.

Will it cause any problems if I use get_template_part() like this?

0

Will it cause any problems if I use get_template_part() like this?

I can't really see any answer other than... no. But that's based on not knowing what you actually mean by "problems".

If you mean "is this code totally bulletproof no matter what scenario you could possible throw at it" then yes, it may cause problems - I don't think you can cover for every eventuality.

But if you mean "am I using the WordPress API in the manner intended/am I doing it right", then yes, you certainly are.

| improve this answer | |

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.