- This topic has 3 replies, 4 voices, and was last updated 1 year, 2 months ago by
priyagchaudhary.
-
AuthorPosts
-
August 8, 2019 at 1:25 am #294081
amandajames
ParticipantI am adding the following code to functions.php
function wpblog_widget() { register_sidebar(array( 'name' => __('Primary Sidebar', 'wpb'), 'id' => 'primary_sidebar', // unique-sidebar-id 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); } add_action('widgets_init', 'wpblog_widget');
This is to register a widget and to make the widget area visible I am dding this code in sidebar.php
<?php if ( is_active_sidebar( 'Primary Sidebar' ) ) : ?> <?php dynamic_sidebar( 'Primary Sidebar' ); ?> <?php endif; ?>
I don’t know why it is not working? I have seen the code here https://www.wpblog.com/how-to-add-custom-widget-area-to-wordpress-themes/
August 8, 2019 at 3:34 pm #294117uxfed
ParticipantIs your widget position showing in the backend? And if so, what have you tried to include in that widget position?
September 27, 2019 at 9:07 am #296515farbyte
ParticipantI think you should be extending the WP_Widget class.
This tutorial looks pretty good:
https://kinsta.com/blog/create-wordpress-widget/January 17, 2020 at 4:28 am #302136priyagchaudhary
ParticipantI am trying to say yo just add some step , i hope you can add custom widgets
Create your widget’s class by extending the standard WP_Widget class and some of its functions.
Register your widget so that it’s made available in the Widgets screen.
Make sure that your theme has at least one widget area in which to add the widgets. -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.