• Hey guys,
    I want to develop a widget that shows the most recent posts.
    For some reason the following code doesn’t format the post content… (The post content is displayed without any formatting like <p></p> or
    etc.)

    /**
         * Outputs the HTML for this widget.
         *
         * @param array  An array of standard parameters for widgets in this theme
         * @param array  An array of settings for this widget instance
         * @return void Echoes it's output
         **/
        public function widget( $args, $instance )
        {
            // Add any html to output the image in the $instance array´
    
    		$count = (!empty( $new_instance['count'] )) ? $new_instance['count'] : 1;
    
    		$args2 = array(
    			'numberposts' => $count,
    			'orderby' => 'post_date',
    			'order' => 'DESC',
    			'post_type' => 'post',
    			'post_status' => 'draft, publish, future, pending, private',
    			'suppress_filters' => false );
    
    		$recent_posts = wp_get_recent_posts( $args2, OBJECT );
    
    		foreach( $recent_posts as $recent ){
    		?>
    			<h1><?php echo $recent->post_title ?></h1>
    			<div class='entry-content'>
    			<p>
    			<span class="entry-date"><?php echo get_the_date("F Y", $recent->id); ?></span><br/>
    			<?php echo $recent->post_content;  ?>
    			</p>
    			</div>
    		<?php
    		}
        }

    Can someone help me?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Show Recent Posts Widget’ is closed to new replies.