<?php /* Template Name: Recent question  */
get_header();
	$active_sticky = true;
	$paged         = (get_query_var("paged") != ""?(int)get_query_var("paged"):(get_query_var("page") != ""?(int)get_query_var("page"):1));
	include("includes/sticky-question.php");
	$custom_args = (isset($custom_args) && is_array($custom_args)?$custom_args:array());
	$args = array_merge($custom_args,array("paged" => $paged,"post_type" => "question","posts_per_page" => get_option("posts_per_page"),
		"meta_query" => array(
			'relation' => 'AND',
			array("key" => "user_id","compare" => "NOT EXISTS"),
			array(
				'relation' => 'OR',
				array(
					'relation' => 'AND',
					array("key" => "sticky","compare" => "NOT EXISTS"),
					array("key" => "start_sticky_time","compare" => "NOT EXISTS"),
					array("key" => "end_sticky_time","compare" => "NOT EXISTS")
				),
				array(
					'relation' => 'AND',
					array("key" => "sticky","compare" => "=","value" => 1),
					array("key" => "end_sticky_time","type" => "NUMERIC","compare" => "<","value" => strtotime(date("Y-m-d")))
				)
			)
		)
	));
	query_posts($args);
	$active_sticky = false;
	get_template_part("loop-question");
	vpanel_pagination();
	wp_reset_query();
get_footer();?>