How to make widget appear conditionally

You should put the conditional at the start of the widget() function: public function widget( $args, $instance ) { // Not single post or not in the pladeanmeldelser category. if ( ! is_single() || ! in_category(‘pladeanmeldelser’) ) { return; } $title = apply_filters( ‘widget_title’, $instance[ ‘title’ ] ); // … other code. } And that … Read more

My website is not showing Footer section

Please add below code in your footer.php file above included JavaScript files : <?php if ( is_active_sidebar( ‘footer-1’ ) ){ dynamic_sidebar( ‘footer-1’ ); } if ( is_active_sidebar( ‘footer-2’ ) ){ dynamic_sidebar( ‘footer-2’ ); } if ( is_active_sidebar( ‘footer-3’ ) ){ dynamic_sidebar( ‘footer-3’ ); } ?>

Add class to on sidebar widget

In functions.php file : add_action( ‘widgets_init’, ‘my_register_sidebars’ ); function my_register_sidebars() { /* Register the ‘primary’ sidebar. */ register_sidebar( array( ‘id’ => ‘sidebar-2’, ‘name’ => __( ‘Main Sidebar’, ‘mystic’ ), ‘description’ => __( ‘A short description of the sidebar.’, ‘mystic’ ), ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h3 class=”widget-title”>’, ‘after_title’ => … Read more

Widget Title is not saving in backend

It’s because you’re always outputting the default value into the input, regardless of what the saved value is: <input class=”widefat” id=”<?php echo esc_attr( $this->get_field_id( ‘title’ ) ); ?>” name=”<?php echo esc_attr( $this->get_field_name( ‘title’ ) ); ?>” type=”text” value=”<?php echo esc_attr( $defaults[‘title’] ); ?>” /> Specifically: value=”<?php echo esc_attr( $defaults[‘title’] ); ?>” $defaults[‘title’] is always going … Read more

How to add shortcode to html widget

First thing you need to do is drag & drop a Text widget to your WordPress sidebar on the Appearance » Widgets screen in your dashboard. After adding the widget, you can simply add your shortcode inside the text edit area of the widget.

Widgets not showing on custom theme

Try to combine both sidebars/arrays into one function. function my_widgets() { register_sidebar( array( ‘id’ => ‘contact-info’, // add the rest here ), register_sidebar( array( ‘id’ => ‘social-links’, // add the rest here )) ); } add_action(‘widgets_init’, ‘my_widgets’); Then you call the deisred sidebar <?php if(is_active_sidebar(‘contact-info’)) : ?> <?php dynamic_sidebar(‘contact-info’); ?> <?php endif; ?>