예제 #1
0
function cp_todays_count_widget($post_type, $limit)
{
    $args = array('post_type' => $post_type, 'posts_per_page' => $limit, 'paged' => 1, 'no_found_rows' => true);
    $popular = new CP_Popular_Posts_Query($args, 'today');
    echo '<ul class="pop">';
    // must be views today
    if ($popular->have_posts()) {
        while ($popular->have_posts()) {
            $popular->the_post();
            echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a> (' . appthemes_get_stats_by(get_the_ID(), 'today') . '&nbsp;' . __('views', APP_TD) . ')</li>';
        }
    } else {
        echo '<li>' . __('No ads viewed yet.', APP_TD) . '</li>';
    }
    echo '</ul>';
    wp_reset_postdata();
}
function cp_get_popular_ads()
{
    global $cp_has_next_page;
    $popular = new CP_Popular_Posts_Query();
    if (!$popular->have_posts()) {
        return false;
    }
    $cp_has_next_page = $popular->max_num_pages > 1;
    return $popular;
}
<?php

/**
 * popular posts on blog for tabbed sidebar
 * shows most popular posts within the last 3 months
 * or overall if any found based on page views
 */
global $post;
// give us the most popular blog posts based on page views, last 3 months
$lastmonths = appthemes_mysql_date(current_time('mysql'), -90);
$args = array('post_type' => 'post', 'posts_per_page' => 5, 'paged' => 1, 'no_found_rows' => true, 'date_start' => $lastmonths);
$popular = new CP_Popular_Posts_Query($args);
// give us the most popular blog posts based on page views, overall
if (!$popular->have_posts()) {
    unset($args['date_start']);
    $popular = new CP_Popular_Posts_Query($args);
}
?>


<ul class="pop-blog">

	<?php 
if ($popular->have_posts()) {
    while ($popular->have_posts()) {
        $popular->the_post();
        ?>

		<li>

			<div class="post-thumb">