Adding custom html widget anywhere on page
-
Hi, I’m trying to change the location of the widgets on my home page. So I made a new <section> and am trying to call a custom html widget there, instead of just typing it up in html inside index.php. I am able to call the wordpress built in widgets with “the_widget(‘WP_xxx”); but I can’t seem to figure out how to call on the ones I made, specifically one with an ID custom_html-2.
I’m using the underscores theme and they have the register sidebar function in the code but I think I still need to give a class to the custom widgets to be able to call it ? and not sure how to apply that.
It seems simple but I’m a bit stuck and can’t really find any similar questions
function peto_theme_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'peto_theme' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'peto_theme' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'peto_theme_widgets_init' );
The page I need help with: [log in to see the link]
- The topic ‘Adding custom html widget anywhere on page’ is closed to new replies.