<?php
$time=time();
$totime=date('H', $time);
$fulldate=date('Y-m-d H:i:s', $time);
$fromtime=$time-86400;
$fromtime=date('Y-m-d H:i:s', $fromtime);
$getposts=mysql_query("select ID FROM blog_posts WHERE post_type='post' AND post_status='publish' AND post_date BETWEEN '$fromtime' AND '$fulldate'");
$getposts=mysql_num_rows($getposts);
if($getposts==0)
{
$poststoday='Det har ikke blitt publisert noen som helst poster de siste 24 timer.';
}
else
{
$poststoday='Siste 24 timer er det slengt opp '.$getposts.' poster til databasen.';
}
echo $poststoday;
?>
<?php
function wp_posts_in_days( $args = '' ) {
global $wpdb;
$defaults = array(
'echo' => 1,
'days' => 30,
'lookahead' => 0
);
$the_args = wp_parse_args( $args, $defaults );
extract( $the_args , EXTR_SKIP );
unset( $args , $the_args , $defaults );
$days = intval( $days );
$operator = ( $lookahead != false ) ? '+' : '-';
$postsindays = $wpdb->get_col( "
SELECT COUNT(ID)
FROM $wpdb->posts
WHERE (1=1
AND post_type = 'post'
AND post_status = 'publish'
AND post_date >= '" . date('Y-m-d', strtotime("$operator$days days")) . "')"
);
if($echo != false) :
echo $postsindays[0];
else :
return $postsindays[0];
endif;
return;
}
?>
// wp_posts_in_days('days=5');
// wp_posts_in_days('days=5&lookahead=1&echo=1');
echo wp_posts_in_days('days=5&echo=0');
takker for løsninger! gikk for picxx sin løsning, fungerte rett ut av boksen