I need to display my custom widget in a WP based custom page template.
This is the scenario:
I created a page based on a custom page template called "product", and now I need my custom widget to appear on its sidebar. I need this sidebar to be completely different from other pages, so I want to display it programmatically. I tried to use the_widget () function, but I think that it only works with built-in widgets, and I also donβt know how to pass parameters registered with the register_sidebar function to it, because it seems that they do not use them by default.
Actually I used this: the_widget ('WP_Widget_Search') for testing, and the widget was there, but it ignored the theme settings, I mean the settings in function.php:
register_sidebar( array(
'name' => 'Sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div></div>',
'before_title' => '<h3>',
'after_title' => '</h3><div class="padder">'
) );
Therefore, as I said, I do not know if it works with custom widgets (created in plugins), because I do not know how to pass the widget name and parameters. How to do it?
source
share