Created
October 30, 2013 07:36
-
-
Save funteractive/7228521 to your computer and use it in GitHub Desktop.
スラッグからpostオブジェクトを取得
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 | |
function get_post_by_slug( $post_name, $post_type = 'post' ){ | |
$args = array( | |
'name' => $post_name, | |
'post_type' => $post_type, | |
'posts_per_page' => 1 | |
); | |
$the_post = get_posts( $args ); | |
$the_post = $the_post[0]; | |
return $the_post; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment