Last active
August 29, 2015 14:26
-
-
Save hayashikejinan/fcfb7ba6e582b388ac96 to your computer and use it in GitHub Desktop.
WordPress で次回予告 (一番近い未来の予約投稿タイトル、無ければ下書きの) を取得するおれおれ関数
This file contains hidden or 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 | |
| /** | |
| * @author hayashikejinan | |
| * @copyright Copyright (c) 2015, hayashikejinan | |
| * @link http://hayashikejinan.com/ | |
| * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | |
| * @return string|void | |
| */ | |
| function hogehoge_get_feature_post_title() { | |
| $feature_posts_args = array( | |
| 'posts_per_page' => 1, | |
| 'category' => '', | |
| 'category_name' => '', | |
| 'orderby' => 'date', | |
| 'order' => 'ASC', | |
| 'include' => '', | |
| 'exclude' => '', | |
| 'meta_key' => '', | |
| 'meta_value' => '', | |
| 'post_type' => 'post', | |
| 'post_status' => 'future', | |
| ); | |
| $feature_posts = get_posts( $feature_posts_args ); | |
| if ( empty( $feature_posts ) ) { | |
| $feature_posts_args['post_status'] = 'draft'; | |
| $draft_posts_args = $feature_posts_args; | |
| $draft_posts = get_posts( $draft_posts_args ); | |
| $feature_posts = $draft_posts; | |
| } | |
| return reset( $feature_posts )->post_title ? esc_attr( reset( $feature_posts )->post_title ) : ''; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment