2013-10-25 92 views
0

我正在使用WordPress自定義內容類型管理器來構建文學代理網站。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;?> 

我到處搜索,但奮鬥適應解決方案到我現有的代碼。

回答

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 
    } 
?> 
+0

由於某些原因,顯示縮略圖的部分變爲空白。我對此有點新鮮。我需要知道如何將任何解決方案整合到我現有的代碼中。如果你能向我展示我的代碼,那將是很棒的。謝謝 – user2918653