在 wordpress 中创建按字母顺序的分页 [英] Create alphabetical Pagination in wordpress
问题描述
我需要在 wordpress 中显示按字母顺序分页的姓名列表.
示例....选择b时.
A B C D...X Y Z
巴西尔 |巴斯蒂安 |贝尔塔 |比利 |拜诺
当我单击 A 时,我只需要以 A 开头的名称...
我在 PasteBin 上找到了这个代码 ...但它创建了完整的列表,
我需要所有字母都显示为 A B C D ..... X Y Z ..... 并且只显示选择了起始字母的名称...
也许不是最好的方法,尽管我就是这样做的.
<div><div class="alphanav"><a href="<?php bloginfo('url'); ?>/shops/?character=A">A</a><a href="<?php bloginfo('url'); ?>/shops/?character=B">B</a><a href="<?php bloginfo('url'); ?>/shops/?character=C">C</a>
<div><h1><?php the_title();?></h1><div id="a-z"><?php$paged = (get_query_var('paged')) ?get_query_var('paged') : 1;$args = 数组 ('posts_per_page' =>$posts_per_page,'post_type' =>'店铺','orderby' =>'标题','订单' =>'ASC','分页' =>$分页);query_posts($args);如果 ( have_posts() ) {而 ( have_posts() ) {the_post();$first_letter = strtoupper(substr(apply_filters('the_title',$post->post_title),0,1));if ($first_letter == $curr_letter) { ?><div class="title-cell"><a href="<?php the_permalink() ?>"rel="bookmark" title="永久链接到<?php the_title_attribute(); ?>"><?php the_title();?></a></div><?php } ?><?php } ?><?php } else {echo "<h2>抱歉,没有找到任何帖子!</h2>";}?></div><!-- End id='a-z'-->
I need to display list of names with alphabetical pagination in wordpress.
Example.... when B is selected..
A B C D...X Y Z
Bassil | Bastien | Belta | Billy | Bynoo
and when i click A, i need only names starting with A...
I found this code on PasteBin ... but it create the full list,
I need all letters to appear like A B C D ..... X Y Z ........... and only display names with starting letter selected...
Maybe not the best method, although this is how I just did it.
<?php
/**
* Template Name: Shop
**/
$posts_per_row = -1;
$posts_per_page = -1;
$curr_letter = $_GET["character"];
?>
<div>
<div class="alphanav">
<a href="<?php bloginfo('url'); ?>/shops/?character=A">A</a>
<a href="<?php bloginfo('url'); ?>/shops/?character=B">B</a>
<a href="<?php bloginfo('url'); ?>/shops/?character=C">C</a>
</div>
<div>
<h1><?php the_title(); ?></h1>
<div id="a-z">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array (
'posts_per_page' => $posts_per_page,
'post_type' => 'shop',
'orderby' => 'title',
'order' => 'ASC',
'paged' => $paged
);
query_posts($args);
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
$first_letter = strtoupper(substr(apply_filters('the_title',$post->post_title),0,1));
if ($first_letter == $curr_letter) { ?>
<div class="title-cell"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<?php } ?>
<?php } ?>
<?php } else {
echo "<h2>Sorry, no posts were found!</h2>";
}
?>
</div><!-- End id='a-z' -->
</div>
</div>
这篇关于在 wordpress 中创建按字母顺序的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!