Created
November 19, 2011 03:30
-
-
Save miya0001/1378387 to your computer and use it in GitHub Desktop.
指定された期限内の記事だけを取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
現在の日時から2日後のタイムスタンプを保存する | |
$d = 2 * 60 * 60 * 24; // 2日間 | |
$expire = current_time('timestamp', get_option("gmt_offset")) + $d; | |
update_post_meta($post->ID, '_expire', $expire); | |
*/ | |
// 現在のローカルタイムスタンプ | |
$now = current_time('timestamp', get_option("gmt_offset")); | |
$args = array( | |
'post_type' => 'one_line_comment', | |
'taxonomy' => 'span', | |
'posts_per_page' => 5, | |
'order' => 'ASC', | |
'meta_key' => '_expire', | |
'meta_value' => $now, | |
'meta_compare' => '>', | |
); | |
$posts = get_posts($args); | |
foreach($posts as $post) { | |
setup_postdata($post); | |
// 必要な処理 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment