Example #1
0
                                        <?php 
$args = array(array('hour' => 48, 'compare' => '<='), 'posts_per_page' => 6, 'orderby' => 'meta_value_num', 'meta_key' => 'post_views_count', 'order' => 'DESC');
$the_query = new WP_Query($args);
// The Loop
if ($the_query->have_posts()) {
    while ($the_query->have_posts()) {
        $the_query->the_post();
        ?>
                                                    <li> 
            											<a href="<?php 
        esc_url(the_permalink());
        ?>
">
            												<div class="avatar-img"> 
            													<img src="<?php 
        echo get_bg_image(get_the_ID());
        ?>
" alt="<?php 
        the_title();
        ?>
">
            												</div>
            												<div class="right-list-baiviet">
            													<div class="content-baiviet"><?php 
        the_title();
        ?>
</div>
            												
            												</div> 
            											</a>
            										</li>
Example #2
0
function get_videos()
{
    $current_date = $_POST['current_date'];
    $video_cat = $_POST['video_cat'];
    $args = array('cat' => $cat_ID, 'post_type' => 'video', 'date_query' => array(array('before' => $current_date)), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC');
    //var_dump($args);
    $the_query = new WP_Query($args);
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $para_print_post = array('id' => get_the_ID(), 'title' => get_the_title(), 'link' => esc_url(get_permalink()), 'date' => get_the_date('d/m/Y  H:i'), 'except' => get_the_excerpt(), 'image_link' => get_bg_image(get_the_ID()));
            $lastDate = get_the_date('Y-m-d H:i:s');
            print_video($para_print_post);
        }
        echo '<input type="hidden" class="lastpost_date" value="' . $lastDate . '">';
    } else {
        echo '<div id="no_news" class="pager pager-padding" style="background-color: #fff;"> 
				    <a class="btn-block btn-md btn"><span>Không còn tin để hiển thị</span></a>
                </div>';
    }
    die;
}