public function widget($args, $instance) { $title = apply_filters('widget_title', @$instance['title']); $number = apply_filters('widget_number', @$instance['number']); $categ = apply_filters('widget_categ', @$instance['categ']); $weekly = apply_filters('widget_weekly', @$instance['weekly']); $monthly = apply_filters('widget_monthly', @$instance['monthly']); $yearly = apply_filters('widget_yearly', @$instance['yearly']); // Before and after the widget echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . esc_html($title) . $args['after_title']; } // The Output echo '<div class="custom-posts"><ul>'; if ($categ != null) { $categ_name = get_cat_name($categ); $categ_ID = get_cat_ID($categ_name); $categ_slug = wise_get_cat_slug($categ_ID); } else { $categ_slug = null; } $popularpost = new WP_Query(array('year' => $yearly, 'monthnum' => $monthly, 'w' => $weekly, 'posts_per_page' => $number, 'category_name' => $categ_slug, 'meta_key' => 'wise_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => 1)); while ($popularpost->have_posts()) { $popularpost->the_post(); echo '<li>' . '<a href="' . esc_url(esc_url(get_the_permalink())) . ' "> '; if (has_post_thumbnail()) { echo '<span class="alignleft-side">'; echo the_post_thumbnail('wise-side-thumb'); echo '</span>'; } else { null; } echo '<div class="url-popular"><h4>' . get_the_title() . '</h4><span class="entry-meta-popular">'; echo wise_posted_on() . '</span></div></a></li>'; } wp_reset_query(); echo '</ul></div><!-- End Popular Posts -->'; echo $args['after_widget']; }
public function widget($args, $instance) { $title = apply_filters('widget_title', @$instance['title']); $number = apply_filters('widget_number', @$instance['number']); $categ = apply_filters('widget_categ', @$instance['categ']); $order = apply_filters('widget_order', @$instance['order']); // Before and after the widget echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . esc_html($title) . $args['after_title']; } // The Output echo '<div class="custom-posts"><ul>'; if ($categ != null) { $categ_name = get_cat_name($categ); $categ_ID = get_cat_ID($categ_name); $categ_slug = wise_get_cat_slug($categ_ID); } else { $categ_slug = null; } $the_query = new WP_Query(array('posts_per_page' => $number, 'category_name' => $categ_slug, 'ignore_sticky_posts' => 1, 'post_status' => "publish", 'post_type' => "post", 'orderby' => $order)); while ($the_query->have_posts()) { $the_query->the_post(); echo '<li>' . '<a href="' . esc_url(esc_url(get_the_permalink())) . ' "> '; if (has_post_thumbnail()) { echo '<span class="alignleft-side">'; echo the_post_thumbnail('wise-side-thumb'); echo '</span>'; } else { null; } echo '<div class="url-popular"><h4>' . get_the_title() . '</h4><span class="entry-meta-popular">'; echo wise_posted_on() . '</span></div></a></li>'; } wp_reset_postdata(); echo '</ul></div><!-- End Recent Posts -->'; echo $args['after_widget']; }
?> </div><!-- End of .top-meta --> <?php the_title('<h2 class="entry-title">', '</h2>'); ?> <div class="entry-meta"> <?php echo wise_entry_header(); ?> <br> <?php wise_posted_on(); wise_posted_by(); echo '<span class="post-views"> ' . wise_get_post_views(get_the_ID()) . '</span>'; wise_comments(); ?> </div><!-- End of .entry-meta --> <div class="share-entry-meta"> <?php get_template_part('templates/custom-social'); ?> </div><!-- End of Custom Social --> </header><!-- End of .entry-header --> <?php if (has_post_thumbnail()) { echo '<div class="single-post-thumb">';
public function widget($args, $instance) { // For Popular Posts $title_ppl = apply_filters('widget_title_ppl', @$instance['title_ppl']); $number_ppl = apply_filters('widget_number_ppl', @$instance['number_ppl']); $categ_ppl = apply_filters('widget_categ_ppl', @$instance['categ_ppl']); $weekly_ppl = apply_filters('widget_weekly_ppl', @$instance['weekly_ppl']); $monthly_ppl = apply_filters('widget_monthly_ppl', @$instance['monthly_ppl']); $yearly_ppl = apply_filters('widget_yearly_ppl', @$instance['yearly_ppl']); // For Recent Posts $title_crp = apply_filters('widget_title_crp', @$instance['title_crp']); $number_crp = apply_filters('widget_number_crp', @$instance['number_crp']); $categ_crp = apply_filters('widget_categ_crp', @$instance['categ_crp']); $order_crp = apply_filters('widget_order_crp', @$instance['order_crp']); ?> <div class="widget tab-sidebar"> <ul class="nav nav-pills"> <li class="active"><a data-toggle="tab" href="#popular"><?php echo esc_attr($title_ppl); ?> </a></li> <li><a data-toggle="tab" href="#recent"><?php echo esc_attr($title_crp); ?> </a></li> </ul> <div class="tab-content"> <div id="popular" class="tab-pane fade in active"> <?php // Output for Popular Posts echo '<div class="custom-posts"><ul>'; if ($categ_ppl != null) { $categ_name_ppl = get_cat_name($categ_ppl); $categ_ID_ppl = get_cat_ID($categ_name_ppl); $categ_slug_ppl = wise_get_cat_slug($categ_ID_ppl); } else { $categ_slug_ppl = null; } $popularpost_ppl = new WP_Query(array('year' => $yearly_ppl, 'monthnum' => $monthly_ppl, 'w' => $weekly_ppl, 'posts_per_page' => $number_ppl, 'post_type' => "post", 'category_name' => $categ_slug_ppl, 'meta_key' => 'wise_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => 1)); while ($popularpost_ppl->have_posts()) { $popularpost_ppl->the_post(); echo '<li>' . '<a href="' . esc_url(esc_url(get_the_permalink())) . ' "> '; if (has_post_thumbnail()) { echo '<span class="alignleft-side">'; echo the_post_thumbnail('wise-side-thumb'); echo '</span>'; } else { null; } echo '<div class="url-popular"><h4>' . get_the_title() . '</h4><span class="entry-meta-popular">'; echo wise_posted_on() . '</span></div></a></li>'; } wp_reset_postdata(); echo '</ul></div><!-- End Popular Posts -->'; ?> </div> <div id="recent" class="tab-pane fade"> <?php // Output for Recent Posts echo '<div class="custom-posts"><ul>'; if ($categ_crp != null) { $categ_name_crp = get_cat_name($categ_crp); $categ_ID_crp = get_cat_ID($categ_name_crp); $categ_slug_crp = wise_get_cat_slug($categ_ID_crp); } else { $categ_slug_crp = null; } $the_query_crp = new WP_Query(array('posts_per_page' => $number_crp, 'category_name' => $categ_slug_crp, 'ignore_sticky_posts' => 1, 'post_status' => "publish", 'post_type' => "post", 'orderby' => $order_crp)); while ($the_query_crp->have_posts()) { $the_query_crp->the_post(); echo '<li>' . '<a href="' . esc_url(esc_url(get_the_permalink())) . ' "> '; if (has_post_thumbnail()) { echo '<span class="alignleft-side">'; echo the_post_thumbnail('wise-side-thumb'); echo '</span>'; } else { null; } echo '<div class="url-popular"><h4>' . get_the_title() . '</h4><span class="entry-meta-popular">'; echo wise_posted_on() . '</span></div></a></li>'; } wp_reset_postdata(); echo '</ul></div><!-- End Recent Posts -->'; ?> </div> </div> </div> <?php }