Created
September 10, 2014 02:02
-
-
Save k4zuki02h4t4/dcfb5f045fa8264e5f7d to your computer and use it in GitHub Desktop.
[ WordPress ] フロントページの設定で、フロントページと投稿ページを設定していて is_home() && ! is_front_page() な情報を取得した時に役にたつかも?なコード
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 | |
/** | |
* Alternative get_post function. | |
* @return object|false | |
*/ | |
public static function my_get_post() { | |
$result = get_post(); | |
$page_for_posts = get_option( 'page_for_posts' ); | |
if ( is_home() && $page_for_posts && ( ! is_object( $result ) || ( $page_for_posts != $result->ID ) ) ) { | |
$result = get_post( $page_for_posts ); | |
} | |
if ( ! is_object( $result ) ) { | |
$result = false; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment