enter image description here

I trying to make widget for display something but is not display on admin->appearance section.
below code i write on functions.php file
below function is working except widget.
like menu,icon, working fine
i tired to make widget.
anybody here who help me
kind regard.
and thanks in advance .

<?php
class jpen_Category_List_Widget extends WP_Widget {
  // php classnames and widget name/description added
  function __construct() {
    $widget_options = array(
      'classname' => 'jpen_category_list_widget',
      'description' => 'Add a nicely formatted list of categories to your sidebar.'
    );
    parent::__construct( 
      'jpen_category_list_widget', 
      'Simple Blog Theme Category List', 
      $widget_options 
    );
  }
  // create the widget output
  function widget( $args, $instance ) {
    
    $title = apply_filters( 'widget_title', $instance[ 'title' ] );
    $categories = get_categories( array(
      'orderby' => 'name',
      'order'   => 'ASC'
      ) );
    $cat_count = 0;
    $cat_col_one = [];
    $cat_col_two = [];
    foreach( $categories as $category ) {
      $cat_count ++;
      $category_link = sprintf( 
          '<li class="list-unstyled"><a href="%1$s" alt="%2$s">%3$s</a></li>',
          esc_url( get_category_link( $category->term_id ) ),
          esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ),
          esc_html( $category->name )
      );
      if ($cat_count % 2 != 0 ) {
        $cat_col_one[] = $category_link;
      } else {
        $cat_col_two[] = $category_link;
      }
    }
    echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
    ?><div class="row">
      <div class="col-lg-6"><?php
        foreach( $cat_col_one as $cat_one ) {
          echo $cat_one;
        } ?>
      </div>

      <div class="col-lg-6"><?php 
        foreach( $cat_col_two as $cat_two ) {
          echo $cat_two;
        } ?>
      </div>

    </div><?php
    echo $args['after_widget'];
  }
  function form( $instance ) { 
    $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; ?>
    <p>
      <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label>
      <input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" />
    </p>
    <p>This widget displays all of your post categories as a two-column list (or a one-column list when rendered responsively).</p>
  <?php }
  // Update database with new info
  function update( $new_instance, $old_instance ) { 
    $instance = $old_instance;
    $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
    return $instance;
  }
}
// register the widget
function jpen_register_widgets() { 
  register_widget( 'jpen_Category_List_Widget' );
}
add_action( 'widgets_init', 'jpen_register_widgets' );
////////////////////
add_theme_support('menu');
function register_newtheme_menu(){
    register_nav_menus(
            array(
                'main-menu'=>_('Main Menu')
            )
    );
    
}

add_action('init','register_newtheme_menu');


function add_menuclass($ulclass) {
   return preg_replace('/<a /', '<a class="navigation-link w-nav-link" ', $ulclass);
}
add_filter('wp_nav_menu','add_menuclass');

function theme_prefix_setup() {
	
	add_theme_support( 'custom-logo', array(
		'height'      => 100,
		'width'       => 400,
		'flex-width' => true,
	) );

}
add_action( 'after_setup_theme', 'theme_prefix_setup' );

?>

Read more here: WordPress Widget is not display on (AdminPanel)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: