I have a standard widget which I've included in my footer with
<?php get_sidebar(); ?>
The content of the widget is visible only in categories pages. e.g. archive.php
.
How can I show it on other pages too? It is included with the footer on all pages, like this:
<?php get_footer(); ?>
In the footer.php I have
<div class="footer-center" data-equalizer-watch>
<div class="baseline">
<div class="newsletter">
<?php get_sidebar(); ?>
</div>
</div>
</div>
UPDATE
<div class="newsletter">
<?php dynamic_sidebar( 'sidebar' ); ?>
</div>
Just changed get_sidebar();
to dynamic_sidebar( 'sidebar' );
Widget function in functions.php
//Stay Connected widget
add_filter( 'widget_text', 'do_shortcode' );
function stay_connected_load_widget() {
register_widget( 'stay_connected_widget' );
}
add_action( 'widgets_init', 'stay_connected_load_widget' );
class stay_connected_widget extends WP_Widget {
function __construct() {
parent::__construct(
'stay_connected_widget',
__('Stay Connected', 'stay_connected_widget_domain'),
array( 'description' => __( 'Social networks and subscribe form', 'stay_connected_widget_domain' ))
);
}
//Widget frontend
public function widget( $args, $instance ) {
$cf7_form = apply_filters( 'widget_title', $instance['cf7_form'] );
echo $args['before_widget'];
// echo $args['before_title'] . '<h4>' . __( 'Stay Connected', 'stay_connected_widget_domain' ) . '</h4>' .$args['after_title'];
?>
<?php
if(!empty( $cf7_form )){
echo '<h4 class="form_title">'. __('Subscribe By Email').'</h4>';
echo '<div class="stay_connected_form">'.do_shortcode(html_entity_decode($cf7_form)).'</div>';
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'cf7_form' ] ) ) {
$cf7_form = $instance[ 'cf7_form' ];
}
else {
$cf7_form = __( '', 'stay_connected_widget_domain' );
}
?>
<p>
<label for="<?php echo $this->get_field_id( 'cf7_form' ); ?>"><?php _e( 'Contact Form:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'cf7_form' ); ?>" name="<?php echo $this->get_field_name( 'cf7_form' ); ?>" type="text" value="<?php echo esc_attr( $cf7_form ); ?>" placeholder="[<?php _e('contact form shortcode'); ?>]"/>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['cf7_form'] = ( ! empty( $new_instance['cf7_form'] ) ) ? strip_tags( $new_instance['cf7_form'] ) : '';
return $instance;
}
}
Update
Array (
[wp_inactive_widgets] => Array ( )
[header] => Array (
[0] => media_gallery-2
)
[footer] => Array (
[0] => custom_html-2
)
[sidebar] => Array (
[0] => stay_connected_widget-3
[1] => search-2
)
[array_version] => 3
)