Title: [Theme: DW Focus]
Last modified: August 22, 2016

---

# [Theme: DW Focus]

 *  [PepinaPress](https://wordpress.org/support/users/pepinapress/)
 * (@pepinapress)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/theme-dw-focus/)
 * Hi, I’m using a newspaper theme called DW FOCUS by DesignWall. The theme features
   a “lastest news” widget that retrieves the last published news and displays them
   as a vertical list. The appearence is ok and it works for my purposes: problem
   is I don’t want to show the LATEST news BUT the news from a precise category.
 * I don’t know exactly what to alter but I think the involved files are the following:
 *     ```
       <?php
       class dw_focus_lastest_news extends WP_Widget {
   
           /**
            * Register widget with WordPress.
            */
           function __construct() {
               parent::__construct(
                   'dw_focus_lastest_news', // Base ID
                   __('DW Focus: Lastest news', 'dw_focus'), // Name
                   array( 'description' => __( 'Display latest news', 'dw_focus' ), ) // Args
               );
           }
   
           /**
            * Front-end display of widget.
            *
            * @see WP_Widget::widget()
            *
            * @param array $args     Widget arguments.
            * @param array $instance Saved values from database.
            */
           public function widget( $args, $instance ) {
               $title = apply_filters( 'widget_title', $instance['title'] );
   
               echo $args['before_widget'];
               if ( ! empty( $title ) )
                   echo $args['before_title'] . $title . $args['after_title'];
                   ?>
                   <?php if ( have_posts() ) : ?>
                       <div class="content-inner">
                           <?php while ( have_posts() ) : the_post(); ?>
                               <?php get_template_part( 'content', 'archive' ); ?>
                           <?php endwhile; ?>
                       </div>
                       <?php dw_focus_pagenavi(); ?>
                   <?php else : ?>
   
                       <?php get_template_part( 'no-results', 'archive' ); ?>
   
                   <?php endif; ?>
   
                   <?php
               echo $args['after_widget'];
           }
   
           /**
            * Back-end widget form.
            *
            * @see WP_Widget::form()
            *
            * @param array $instance Previously saved values from database.
            */
           public function form( $instance ) {
               if ( isset( $instance[ 'title' ] ) ) {
                   $title = $instance[ 'title' ];
               }
               else {
                   $title = __( 'Lastest News', 'dw_focus' );
               }
               ?>
               <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 esc_attr( $title ); ?>">
               </p>
               <?php
           }
   
           /**
            * Sanitize widget form values as they are saved.
            *
            * @see WP_Widget::update()
            *
            * @param array $new_instance Values just sent to be saved.
            * @param array $old_instance Previously saved values from database.
            *
            * @return array Updated safe values to be saved.
            */
           public function update( $new_instance, $old_instance ) {
               $instance = array();
               $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
   
               return $instance;
           }
   
       }
   
       // register dw_focus_lastest_news widget
       function register_dw_focus_lastest_news() {
           register_widget( 'dw_focus_lastest_news' );
       }
       add_action( 'widgets_init', 'register_dw_focus_lastest_news' );
       ```
   
 * As far as I understand this file calls content-archive.php, but I really can’t
   understand how the template uses it and what to alter to have my news coming 
   from only one hard-coded categpry:
 *     ```
       <?php
       /*
        * The template for displaying content on the archive page.
        */
       ?>
   
           <?php
               global $archive_i; $class = '';
               if( isset($archive_i) && $archive_i % 3 == 0 ) {
                   $class = 'first';
               }
               if( has_post_thumbnail( get_the_ID() ) ) {
                   $class .= ' has-thumbnail';
               }
           ?>
           <article id="post-<?php the_ID(); ?>" <?php post_class($class); ?> >
               <?php if( has_post_thumbnail() ) : ?>
               <div class="entry-thumbnail">
                   <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'dw_focus' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
   
                       <?php if ( has_post_format('Video') || has_post_format('Audio') || has_post_format('Gallery')) : ?>
                           <?php echo dw_focus_post_format_icons(); ?>
                       <?php endif ?>
   
                       <?php if( $archive_i == 1 ): ?>
                           <?php the_post_thumbnail('large'); ?>
                       <?php else: ?>
                           <?php the_post_thumbnail('medium'); ?>
                       <?php endif; ?>
                   </a>
   
                   <?php if( $archive_i == 1 ): ?>
                       <header class="entry-header">
                           <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'dw_focus' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
                           </h2>
   
                           <div class="entry-meta entry-meta-top">
                               <span class="author">
                                   <?php
                                       if ( function_exists( 'coauthors_posts_links' ) ) {
                                           coauthors_posts_links();
                                       } else {
                                           the_author_posts_link();
                                       }
                                   ?>
                               </span>
   
                               <?php _e(' - ','dw-focus'); ?>
   
                               <?php echo dw_human_time(); ?>
   
                               <?php _e(' - ','dw-focus'); ?>
   
                               <?php
                                   $categories_list = get_the_category_list( __( ', ', 'dw_focus' ) );
                                   if ( $categories_list && dw_focus_categorized_blog() ) :
                               ?>
                               <span class="cat-links">
                                   <?php printf( '%1$s', $categories_list ); ?>
                               </span>
                               <?php endif; ?>
                           </div>
                       </header>
                   <?php endif; ?>
               </div>
               <?php endif; ?>
               <div class="post-inner">
                   <header class="entry-header">
                       <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'dw_focus' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
   
                       <div class="entry-meta entry-meta-top">
                           <span class="author">
                               <?php
                                   if ( function_exists( 'coauthors_posts_links' ) ) {
                                       coauthors_posts_links();
                                   } else {
                                       the_author_posts_link();
                                   }
                               ?>
                           </span>
   
                           <?php _e(' - ','dw-focus'); ?>
   
                           <?php echo dw_human_time(); ?>
   
                           <?php _e(' - ','dw-focus'); ?>
   
                           <?php
                               $categories_list = get_the_category_list( __( ', ', 'dw_focus' ) );
                               if ( $categories_list && dw_focus_categorized_blog() ) :
                           ?>
                           <span class="cat-links">
                               <?php printf( '%1$s', $categories_list ); ?>
                           </span>
                           <?php endif; ?>
                       </div>
                   </header>
   
                   <div class="entry-content">
                       <?php the_excerpt(); ?>
                   </div><!-- .entry-content -->
   
                   <footer class="entry-meta entry-meta-bottom">
                       <?php
                           /* translators: used between list items, there is a space after the comma */
                           $tags_list = get_the_tag_list( '', __( ', ', 'dw_focus' ) );
                           if ( $tags_list ) :
                       ?>
                       <span class="tags-links">
                           <?php printf( __( 'Tags: %1$s', 'dw_focus' ), $tags_list ); ?>
                       </span>
                       <?php endif; // End if $tags_list ?>
   
                   </footer>
               </div>
           </article>
       ```
   
 * Any help is appreciated!

The topic ‘[Theme: DW Focus]’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [show](https://wordpress.org/support/topic-tag/show/)

 * 0 replies
 * 1 participant
 * Last reply from: [PepinaPress](https://wordpress.org/support/users/pepinapress/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/theme-dw-focus/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
