Wordpress按字母顺序排序自定义字段值
问题描述:
我正在使用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;?>
我到处搜索,但奋斗适应解决方案到我现有的代码。
答
<?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
}
?>
由于某些原因,显示缩略图的部分变为空白。我对此有点新鲜。我需要知道如何将任何解决方案整合到我现有的代码中。如果你能向我展示我的代码,那将是很棒的。谢谢 – user2918653