【发布时间】:2015-02-18 22:45:51
【问题描述】:
我设法设置了一个页面模板来显示我的自定义帖子类型“书籍”并按自定义字段(作者的第二个姓名)对其进行排序:
<?php
// Define custom query parameters
$custom_query_args = array(
'post_type' => 'books',
'showposts' => 10,
'meta_key' => 'author_second_name',
'orderby' => 'meta_value date',
'order' => 'ASC'
);
// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );
// Pagination fix
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $custom_query;
// Output custom query loop
if ( $custom_query->have_posts() ) : ?>
在我的存档页面上,我已经成功实现了 A-Z 分页,并尝试使用以下方法在我的作者页面上进行调整:
<?php echo "<a href=http://mywebsite.com/authors/?$query_string&number=true' ># </a> - ";
foreach (range('A', 'Z') as $i)
{
$letter = strtolower($i);
echo "<a href='mywebsite.com/authors/?$query_string&letter=$letter' >$i </a> - ";
}
echo "<a href=http://mywebsite.com/authors/?$query_string' >All </a>"; ?>
不出所料,这似乎不起作用。为了做到这一点,我已经编写了各种代码,并在原则上理解了其中的大部分内容,但在试图让它工作时有点卡住了。
谁能帮忙?
【问题讨论】:
标签: php wordpress pagination advanced-custom-fields