1

I want to add a hard coded footer into the... footer.php of my site. This doesn't need to be "dynamic" (adding and removing widgets), it will be something standard like info about the site and specific links.

If I am correct this can be done either by get_template_part( 'template-parts/', 'infofooter' );

or by get_sidebar( 'infofooter' );

In the second case I just have to name my file sidebar-infofooter.php

Are both methods equally valid? What is the difference between a (non-dynamic) sidebar and a template part? Is it that a sidebar usually includes widgets?

2

The get_sidebar($name); function loads sidebar template file sidebar-{$name}.php if no name in the prentacies is specified it loads the sidebar.php file.

get_sidebar() and get_template_part() are almost identical, at the end they call locate_template() function that take care of loading from files.

The only difference is the hook fired. If you use get_sidebar() for all your widget areas you can target them all later with get_sidebar hook if needed.

So both options are equally valid in terms of code. They differ in semantics as sidebar usually contains a dynamic_sidebar() area inside the template.

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.