0

我正在使用 WordPress 自定义内容类型管理器来构建一个文学机构网站。

我坚持的页面是作者页面,它显示与作者相关的所有书籍的缩略图。我下面的代码就是这样做的,但是我希望它按字母顺序显示。这是代码:

<?php if (get_custom_field("authimage:get_post")):?>
<div class="thumbstrip">
<h4>Titles by this Author</h4>
<ul>
<?php $my_post = get_custom_field("authimage:get_post");
    if(!empty($my_post)){
        foreach ($my_post as $a) {
            print '<li><a href="'. $a['permalink'] .'" title="'. $a['post_title'] .'"><img src="'.$a ['thumbnail_src'].'" /></a></li>';
        }
    }
?>
<ul>
</div>
<?php endif;?>

我到处搜索,但很难将解决方案适应我现有的代码。

4

1 回答 1

0
<?php 
$args=array(
      'meta_key' => 'authimage',  
      'orderby' => 'meta_value',
      'order' => 'ASC',
      'numberposts' => 99
    );
    $thePosts = get_posts($args);
    $i=1;
    foreach($thePosts as $thisPost){
        $getPost = get_post($thisPost->ID);
         //Whatever you want to do with the post
    }
?>
于 2013-10-25T12:16:52.737 回答