<?php
$day = date('j');
query_posts('post_type=product&day='.$day);
if (have_posts()) :
while (have_posts()) : the_post();
?>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="view: <?php the_title(); ?>"><?php the_title(); ?></a></h3>
<div class="storycontent"><?php the_content(); ?></div>
<?php endwhile; ?>
<?php endif; ?>
نشونم ندادشفکر کنم میشه:
<?php
$day = date('j');
query_posts('post_type=product&day='.$day);
$post_numbers = "0";
if (have_posts()) :
while (have_posts()) : the_post();
$post_numbers++;
endwhile;
?>
امروز <?php echo $post_numbers;?> محصول جدید در فروشگاه قرار گرفته است.
<?php endif; ?>
آزمایش نکردم. نتیجه رو بگو...
function get_posts_count_from_today($post_type ='product') {
global $wpdb;
$numposts = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(ID) ".
"FROM {$wpdb->posts} ".
"WHERE post_status='publish' ".
"AND post_type= %s ".
"AND DATE_FORMAT(post_date, '%Y-%m-%d') = %s",
$post_type, date('Y-m-d', time())
)
);
return $numposts;
}
برای نمایش:
<?php echo get_posts_count_from_today(); ?>
اینو آزمایش کن:
function get_posts_count_from_last_24h($post_type ='product') {
global $wpdb;
$numposts = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(ID) ".
"FROM {$wpdb->posts} ".
"WHERE ".
"post_status='publish' ".
"AND post_type= %s ".
"AND post_date> %s",
$post_type, date('Y-m-d H:i:s', strtotime('-24 hours'))
)
);
return $numposts;
}
برای نمایش:
<?php echo get_posts_count_from_last_24h(); ?>
یا این:
function get_posts_count_from_today($post_type ='product') {
global $wpdb;
$numposts = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(ID) ".
"FROM {$wpdb->posts} ".
"WHERE post_status='publish' ".
"AND post_type= %s ".
"AND DATE_FORMAT(post_date, '%Y-%m-%d') = %s",
$post_type, date('Y-m-d', time())
)
);
return $numposts;
}
برای نمایش:
<?php echo get_posts_count_from_today(); ?>