Umasankar Arulanantham
asked 6 years ago

Example

1 Answers
DominicStaff
answered 6 years ago

Hello Umasankar !
To put 2 Topics with Picture in “DW Focus:Category” widget, You can open the dw-focus-categories.php file in the folder path “\wp-content\themes\dw-focus\inc\widgets”. Find the line 232 to 293 then replace the following code:  

  $i = 0;
            if( $i == 0 ){ $posts->the_post(); $i++;
                $post_class = '';
                if(has_post_thumbnail()) $post_class = 'has-thumbnail';
            ?>
            <div class="span6">
                <article <?php post_class($post_class); ?>>
                    <?php if( has_post_thumbnail( get_the_ID() ) ) { ?>
                    <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 the_post_thumbnail('thumbnail'); ?></a>
                    </div>
                    <?php } ?>

                    <?php if( isset( $instance['meta'] ) && $instance['meta'] ) { ?>
                        <div class="entry-meta">
                        <?php
                            if( isset( $instance['date'] ) && $instance['date'] ) {
                                echo '<div>'.dw_human_time().'</div>';
                            }
                        ?>

                        <?php
                            if( isset( $instance['author'] ) && $instance['author'] ) {
                                _e('by','dw-focus');
                                ?>
                                <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"><?php echo get_the_author(); ?></a>
                                <?php
                            }
                        ?>

                        <?php
                            if( isset( $instance['cat'] ) && $instance['cat'] ) {
                                $categories_list = get_the_category_list( __( ', ', 'dw_focus' ) );
                                    if ( $categories_list && dw_focus_categorized_blog() ) :
                                ?>
                                <span class="cat-links">
                                    <?php printf( __( '<span> on </span>%1$s', 'dw_focus' ), $categories_list ); ?>
                                </span>
                                <?php
                                endif;
                            }
                        ?>
                        </div>
                    <?php } ?>

                    <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-content"><?php the_excerpt();  ?></div>
                </article>
            </div>
            <?php }  ?>

            <div class="span6">
                <ul class="other-entry">
                <?php  
                    while( $posts->have_posts() ) { $posts->the_post();
                ?>
                    <li><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></li>
                <?php } ?>
                </ul>
            </div>

With new code:

 
 $i = 0;
echo '<div class="span6">';
while ( $posts->have_posts() ) { $posts->the_post();
    if ( $i < 2 ) {
        $post_class = '';
        if(has_post_thumbnail()) $post_class = 'has-thumbnail';
        ?>
        <article <?php post_class($post_class); ?>>
            <?php if( has_post_thumbnail( get_the_ID() ) ) { ?>
            <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 the_post_thumbnail('thumbnail'); ?></a>
            </div>
            <?php } ?>

            <?php if( isset( $instance['meta'] ) && $instance['meta'] ) { ?>
                <div class="entry-meta">
                <?php 
                    if( isset( $instance['date'] ) && $instance['date'] ) {
                        echo '<div>'.dw_human_time().'</div>'; 
                    }
                ?>

                <?php 
                    if( isset( $instance['author'] ) && $instance['author'] ) {
                        _e('by','dw-focus');
                        ?>
                        <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"><?php echo get_the_author(); ?></a>
                        <?php
                    }
                ?>

                <?php 
                    if( isset( $instance['cat'] ) && $instance['cat'] ) {
                        $categories_list = get_the_category_list( __( ', ', 'dw_focus' ) );
                            if ( $categories_list && dw_focus_categorized_blog() ) :
                        ?>
                        <span class="cat-links">
                            <?php printf( __( '<span> on </span>%1$s', 'dw_focus' ), $categories_list ); ?>
                        </span>
                        <?php
                        endif;
                    }
                ?>
                </div>
            <?php } ?>

            <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-content"><?php the_excerpt();  ?></div>
        </article>
        <?php
    }
    $i++;
}
echo '</div>';

$j = 0;
echo '<div class="span6"> <ul class="other-entry">';
while ( $posts->have_posts() ) { $posts->the_post();
    if ($j >= 2) {
    ?>
        <li><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></li>
    <?php
    }
    $j++;
}
echo '</ul></div>';
?>

Hope this helps !

Umasankar Arulanantham
replied 6 years ago

Thank you!!

Powered by DW Question & Answer Pro