Wordpress中的随机永久链接

Wordpress中的随机永久链接,wordpress,Wordpress,我写了一个代码来检索随机wp帖子,它工作得很好。问题是它显示了最近添加的媒体及其永久链接。下面的代码中要做什么更改来检索随机永久链接,而不是最近添加的 <? function get_match( $regex, $content ) { preg_match($regex, $content, $matches); return $matches[1]; } $shortcode_args = shortcode_parse_atts(get_match('/\[

我写了一个代码来检索随机wp帖子,它工作得很好。问题是它显示了最近添加的媒体及其永久链接。下面的代码中要做什么更改来检索随机永久链接,而不是最近添加的

<?

function get_match( $regex, $content ) {
    preg_match($regex, $content, $matches);
    return $matches[1];
} 


$shortcode_args = shortcode_parse_atts(get_match('/\[gallery\s(.*)\]/isU', $post->post_content));


$ids = $shortcode_args["ids"];


$attachments = get_posts(
    array(
        'include' => $ids, 
        'post_status' => 'inherit', 
        'post_type' => 'attachment', 
        'post_mime_type' => 'image', 
        'order' => 'menu_order ID', 
        'orderby' => 'post__in', 
    )
);



foreach ($attachments as &$pos) {



$perm = get_permalink($pos->ID);
$img =  wp_get_attachment_link( $pos->ID, 'thumbnail',true  ); 

 echo('<a href="'.$perm.'">'.$img.'</a>');


}
?>
并删除

'post_mime_type' => 'image', 
它工作得很好问题是。。。这句话和问题的其余部分一样有道理
'post_mime_type' => 'image',