Listar ultimas noticias com imagens
-
Olá quero mostrar 3 ultimas noticias com imagens e logo abaixo mostrar uma lista de ultimas noticias também, mas só consigo mostrar a ultima foto.
estou usando o widget:
// =============================== Últimos Posts Publicados ====================================== class UltRecentPosts extends WP_Widget { function UltRecentPosts() { //Constructor $widget_ops = array('classname' => 'widget lista de posts recents', 'description' => 'Lista de ultimos posts' ); $this->WP_Widget('UltRecentPosts', 'Últimos Posts Publicados', $widget_ops); add_action( 'save_post', array(&$this, 'flush_widget_cache') ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); } function widget($args, $instance) { // prints the widget extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $category = empty($instance['category']) ? ' ' : apply_filters('widget_category', $instance['category']); $post_number = empty($instance['post_number']) ? ' ' : apply_filters('widget_post_number', $instance['post_number']); $post_link = empty($instance['post_link']) ? ' ' : apply_filters('widget_post_link', $instance['post_link']); // if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; echo ''; ?> <h3> <span><?php echo $title; ?></span> </h3> <div id="ultimas"> <?php global $post; setup_postdata($post); $postcount = 0; $page = (get_query_var('paged')) ? get_query_var('paged') : 0; query_posts( 'paged=$page&showposts='.$post_number ); if (have_posts()) { while (have_posts()) { the_post(); if( $postcount == 0 ) { //GETS LATEST POST ?> <?php $post_images = bdw_get_images($post->ID,'large');?> <?php if($post_images[0]){ global $thumb_url; ?> <div class="box"> <?php if($post_images[0]){ global $thumb_url;?> <div class="foto"><a>"><img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo $post_images[0];?>&w=131&h=81&zc=1&q=80<?php echo $thumb_url;?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /> </a></div> <?php }?> <h4> <a>"><?php the_title(); ?></a></h4> </div> <?php }?> </div> <div id="ultimas_list" class="list_wise_post"> <ul> <?php } elseif( $postcount > 0 && $postcount <= 5 ) { //GETS MORE EXCERPTS ?> <li> <a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> </li> <?php } $postcount ++; // close the loop } } ?> </ul> <?php echo '</div>'; echo $after_widget; } function flush_widget_cache() { wp_cache_delete('widget_recent_posts', 'widget'); } function update($new_instance, $old_instance) { //save the widget $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['post_number'] = strip_tags($new_instance['post_number']); $instance['post_link'] = strip_tags($new_instance['post_link']); return $instance; } function form($instance) { //widgetform in backend $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'post_number' => '' ) ); $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; ?> <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 $title; ?>" /></p> <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label> <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p> <?php } } register_widget('UltRecentPosts');
Visualizando 4 respostas - 1 até 4 (de um total de 4)
Visualizando 4 respostas - 1 até 4 (de um total de 4)
- O tópico ‘Listar ultimas noticias com imagens’ está fechado para novas respostas.