I came across a very different scenario where I had to use get_sidebar('recommendations') multiple times on one page. But it works only one time.

It works multiple times only when I use include('sidebar-recommendations.php') but I want to go with standardize way in WordPress.

I searched in the code but couldn't find the reason why It doesn't work multiple times?

3 Answers 3


You can't.

get_template() function has a protection against this.

You will have to use include().

  • I would suggest using get_template_part( 'sidebar', 'recommendations' ), as you still keep the core WordPress functionality for hooks & child themes. Aug 27, 2015 at 9:38

get_template_part( 'sidebar', 'recommendations' ) is fine and mostly in use by popular themes ie. "Enfold" Thanx for suggestion @Klian

  • 1
    Please wrap your inline code in »backticks« to format is as such. Further I think, your answer could also been a comment to the answer from Klian as it does not really provide new information.
    – David
    Aug 29, 2015 at 12:01
  • Downvoted because of formatting? This is the correct answer.
    – JeremyE
    Oct 22, 2019 at 7:29

I have an other option as well if it is important to use one sidebar in template more than once, why not to use jQuery and clone that sidebar and by using once and appending that to specific section, but it is important not to use idz in sidebar because multiplications of idz is not valid and may cause layout breakage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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