Site icon Hip-Hop Website Design and Development

How To Add and Show Class Picture

I’ve created a WordPress plugin to create a widget space to show class names (whole nmbr of put up) and outline.Now I wish to present the class picture simply after the class title and after the picture I wish to present class description. Though class names and outline show efficiently I simply need the whole code of how you can add function picture to class and the way that can show in my class description widget space.

For Reference right here is my full Class Description Widget Space code.

<?php
/*
Plugin Identify: My Class Description Widget Plugin
Plugin URI: http://mkrdip.me/category-posts-widget
Description: Provides a widget that exhibits all classes together with their description.
Creator: Muhammad Jahangir
Model: 1.0
Creator URI: http://fb.com/jahangirKhattakPk
*/
class categories_description extends WP_Widget
{
    operate __construct()
    {
        $widget_ops = array( 
            'classname' => 'categoryDescription widget',
            'description' => 'Present all classes with their description.',
        );
        father or mother::__construct( 'categories_description', 'My Class Description', $widget_ops );
    }
    // finish __construct()

    public operate kind( $occasion ) {
        $title = ! empty( $occasion['title'] ) ? $occasion['title'] : __( 'New title', 'text_domain' );
        ?>
        <p>
        <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( esc_attr( 'Title:' ) ); ?></label> 
        <enter class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" title="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" sort="textual content" worth="<?php echo esc_attr( $title ); ?>">
        </p>
        <?php 
    }
    // Finish kind operate

// Updating widget changing previous situations with new
public operate replace( $new_instance, $old_instance ) {
    $occasion = array();
    $occasion['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
    return $occasion;
}
// Finish replace operate
    operate widget($args,$occasion){
           echo $args['before_widget'];
            if ( ! empty( $occasion['title'] ) )
            {


        ?>
        <div class="categoriesDescription bgWhite">
                <div class="container innerContainer">
                    <h2 class="widgetTitle"><?php echo apply_filters( 'widget_title', $occasion['title'] ); } ?></h2>
                        <?php $classes = get_categories();
                        foreach ($classes as $cat)
                            { 

                                $cat_name = $cat->title;
                                $CategoryID = get_cat_ID( $cat_name );
                                $totalPosts = $cat->rely;
                                $currentcatname = $cat_name;



                                ?>

                              <div class="category-image">

                              </div>

                                <div class="singleCategory col-lg-4">
                                    <a href="<?php echo get_category_link( $cat ); ?>" class="uppercase categoryTitle">
                                        <?php echo $cat_name; ?></a>
                                        <span class="numberOfPosts">
                                        <?php 
                                            echo '( '.$totalPosts.' )'; 
                                        ?>
                                </span>                         
                                <div class="CategoryImg"><?php echo $cat->term_icon; ?>
                                    // right here I wish to present class function picture...
                                <div class="my-image">
                                <?php

 ?>
                                <header class="archive-header <?php if ($category_image==true) echo 'category-image'; ?>">

                                 </div>

                                </div>
                                <p class="CategoryDescription"><?php echo $cat->description; ?></p>
                                <p><?php echo $CategoryID; ?></p>
                               </div>
                            <?php 
                            } ?>
                    <div class="clearfix"></div>
                </div>
        </div>
    </div>
</div>
        <?php

    }
    // Finish widget operate
}
//finish categories_description class
    add_action('widgets_init', operate() {
        register_widget('categories_description');
    })
?>