0
오늘 게시 된 게시물을 반향시킬 기능이 있어야합니다.오늘 게시물 만 가져 오시겠습니까?
00.00 - 23.59.
function todayNews() {
$id = mysql_real_escape_string ($id);
$sql = 'SELECT * FROM wp_posts WHERE post_status = "publish" AND post_date = CURRENT_DATE ORDER BY post_date DESC LIMIT 15';
$res = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($res) !=0):
while ($row = mysql_fetch_assoc($res)) {
$title = ($row['post_title']);
$old_date = $row['post_date']; // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('H:i', $old_date_timestamp);
$mycontent = ($row['post_content']);
$mycontent = strip_tags($mycontent);
$mycontent = substr($mycontent,0,350);
$mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent);
$first_img = '';
$my1content = $row['post_content'];
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/img/default.png";
}
echo '
<ul class="li-sub">
<li>
'.$title.'
</li>
</ul>
';
}
else:
echo 'There are no posts for today !';
endif;
} // end
감사합니다 : 함수를 작성하지만이 결과를 제공하지 않는 되 잖아 내가 을 필요로하는 것은 여기 내 기능입니다!
EDIT : POST_DATE이 형식을 가지고 Y-m 차원 H : 제가
무엇을 얻고 있으며 무엇을 얻으려고합니까? –
테이블에'post_date '열의 유형은 무엇입니까? 데이터는 어떻게 저장됩니까? – jprofitt
안녕하세요, post_date 형식에 대한 내 게시물을 수정했습니다! – Meo