Last active
August 29, 2015 14:21
-
-
Save kurozumi/aae057a0f56f1e9d3cf0 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
if (!function_exists('get_rand_permalink')): | |
function get_rand_permalink() | |
{ | |
if($posts = get_posts(array('posts_per_page' => 1, 'orderby' => 'rand'))) | |
{ | |
$post = current($post); | |
return get_permalink($post->ID); | |
} | |
return home_url(); | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment