Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/aae057a0f56f1e9d3cf0 to your computer and use it in GitHub Desktop.
Save kurozumi/aae057a0f56f1e9d3cf0 to your computer and use it in GitHub Desktop.
【ワードプレス】ランダムで投稿情報のパーマリンクを取得する
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