This line of code is incorrect
<?php if ( !function_exists('redmenu_widget') || !dynamic_sidebar('redmenu_widget') ) : ?>
More to the point, your negative operator (!
) is wrong here
That line of code simply translates to
If the function
redmenu_widget
does not exist OR if the sidebarredmenu_widget
does not exists, do something
You should just drop the operator and also the !function_exists('redmenu_widget')
part. You should also rather do a check to see if a sidebar is active. That part of code should look like this
<aside id="widgets">
<?php if ( is_active_sidebar('redmenu_widget') ) : ?>
<div id="primary" class="widget-area">
<ul class="xoxo">
<?php dynamic_sidebar('redmenu_widget'); ?>
</ul>
</div><!-- #primary .widget-area -->
<?php endif; ?>
</aside>
Also, your widget is a complete mess unfortunately. There are are lot of errors. You should check the Widget API and how to correctly create a widget. Also, when registering your widget, you want to use the class name.
EDIT
From your comments, you need a custom text widget. To accomplish this, simply copy the default text widget and customize as needed. Here is the default text widget, I have already renamed it, so you can just copy and paste it into your theme
class Red_Menu_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array( 'classname' => 'redmenu_widget', 'description' => __('Rood menu rechts', 'redmenu_widget') );
$control_ops = array( 'width' => 400, 'height' => 350 );
parent::__construct( 'redmenu_widget', __('Rood menu rechts', 'redmenu_widget'), $widget_ops, $control_ops );
}
public function widget( $args, $instance ) {
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
/**
* Filter the content of the Text widget.
*
* @since 2.3.0
*
* @param string $widget_text The widget content.
* @param WP_Widget $instance WP_Widget instance.
*/
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
echo $args['before_widget'];
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
} ?>
<div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
<?php
echo $args['after_widget'];
}
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
if ( current_user_can('unfiltered_html') )
$instance['text'] = $new_instance['text'];
else
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
$instance['filter'] = isset($new_instance['filter']);
return $instance;
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
$title = strip_tags($instance['title']);
$text = esc_textarea($instance['text']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
<?php
}
}
And then to register it
add_action( 'widgets_init', 'prefix_register_widgets' );
function prefix_register_widgets() {
register_widget( 'Red_Menu_Widget' );
}
You can register your sidebar as per example in your question (just change the id as it might create conflict with your widget, call it something like redmenu-sidebar
) and then call your sidebar as follows in your template file
<aside id="widgets">
<?php if ( is_active_sidebar( 'redmenu_sidebar' ) ) : ?>
<div id="primary" class="widget-area">
<ul class="xoxo">
<?php dynamic_sidebar('redmenu_sidebar'); ?>
</ul>
</div><!-- #primary .widget-area -->
<?php endif; ?>
</aside>
This should do it for you. Modify the code and widget to suit your needs