Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active Aug 29, 2015
Embed
What would you like to do?
【ワードプレス】ランダムで投稿情報のパーマリンクを取得する
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