admin管理员组

文章数量:1426918

I'm looking for a way to have a post template that has two sidebars, one on the right side, the other on the left side, with always the same content on each one of them.

I defined that left sidebar as "sidebaraleatorio", and right sidebar as "sidebarrecomenda", and created for each one of them a .php file, then I registered them in my functions.php of child theme. After that, I created a template trying to call the two sidebars php files:

<?php get_sidebaraleatorio(); ?> <?php get_sidebarrecomenda(); ?>

But when I tested, there were several bugs, so I guess something is wrong in my way of doing it... Shouldn't I create different sidebar php files?

If the problem is not that, I can include the other code I'm using on these files

Thanks a lot for any help

I'm looking for a way to have a post template that has two sidebars, one on the right side, the other on the left side, with always the same content on each one of them.

I defined that left sidebar as "sidebaraleatorio", and right sidebar as "sidebarrecomenda", and created for each one of them a .php file, then I registered them in my functions.php of child theme. After that, I created a template trying to call the two sidebars php files:

<?php get_sidebaraleatorio(); ?> <?php get_sidebarrecomenda(); ?>

But when I tested, there were several bugs, so I guess something is wrong in my way of doing it... Shouldn't I create different sidebar php files?

If the problem is not that, I can include the other code I'm using on these files

Thanks a lot for any help

Share Improve this question asked May 22, 2019 at 17:17 usinausina 133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

If you add sidebar-sidebaraleatorio.php and sidebar-sidebarrecomenda.php sidebar templates to your (child) theme directory, you can then call them with get_sidebar() function.

Like so get_sidebar('sidebaraleatorio); and get_sidebar('sidebarrecomenda);.

You can read more about sidebars from the Developer Handbook > Sidebars.

本文标签: How to create a post template with two sidebars