Header Ads

Header ADS

WP latest post widget development

 

//==========latest post widget development=====


/*

*

* extends class for comm_latest_post widget development

*

*/


class comm_latest_post extends WP_Widget{


public function __construct( ){

parent::__construct('comm_latest_post', 'Commet Latest Post', [

'description'   =>'Commet Latest Post Box'


] );


}


public function widget( $one, $two){    //output set korte hobe eikhane 


$title = $two['title'];

?>  


      <?php echo $one['before_widget']; ?>

              <?php echo $one['before_title']; ?><?php echo $title; ?><?php echo $one['after_title']; ?>

               <ul class="nav">


                <?php 


                $ppppp = new WP_Query([


                'post_type' =>'post',

                'posts_per_page'  =>5


                ]);



                while($ppppp->have_posts()) : $ppppp->the_post();



                ?>

                <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?><i class="ti-arrow-right"></i><span><?php the_time('F d, Y') ?></span></a></li>


            <?php endwhile; ?>

              

              </ul>

           <?php echo $one['after_widget']; ?>






<?php }


public function form($two ){


$title = $two['title'];



?>

<p>

<label for="">Title</label>

<input name="<?php echo $this-> get_field_name('title');?>" value="<?php echo $title; ?>" class="widefat" type="text">

</p>


<?php }




}




//at first widget_init hook er vitore eita rakhte hobe . register_widget('comm_latest_post');  //use for widget development

...................................


No comments

Theme images by fpm. Powered by Blogger.