I have created a wordpress template.
I have added some HTML into a Text widget and saved it.
Is there a way to add some code into my template so I can get that widget to be displayed?
Is this possible instead of having to enter the html code directly into my template?
Your Text widget will be inside of a sidebar. So if you have a sidebar called “left-sidebar”, you can use code like this in your template.
Now all the widgets you put in left-sidebar will be included in that template automatically.
There’s more information about dynamic_sidebar here: https://codex.wordpress.org/Function_Reference/dynamic_sidebar
Note that you can also create new sidebars using register_sidebar in your functions.php, so if you want to use different sidebars in different templates you can. https://codex.wordpress.org/Function_Reference/register_sidebar
Yes it is infact it’s very simple, you have to create a sidebar for where you wan that widget to go. In your main php file or wherever you want that widget to appear you can add the following code:
Then you would also have to declare that sidebar within the functions.php file like so:
and you can have as many sidebars that you want, just give them a different name like sidebar2 etc..