Php 在wordpress中创建字母分页

Php 在wordpress中创建字母分页,php,wordpress,pagination,alphabetical,letters,Php,Wordpress,Pagination,Alphabetical,Letters,我需要在wordpress中显示按字母顺序分页的姓名列表 例如。。。。当选择B时 ABcd…X Y Z 巴希尔|巴斯蒂安|贝尔塔|比利|比诺 当我点击A时,我只需要以A开头的名字 我找到了这个密码。。。但是它创建了完整的列表 我需要所有字母都显示为B C D。。。。。X Y Z。。。。。。。。。。。只显示选择了起始字母的名称…可能不是最好的方法,尽管我就是这样做的 <?php /** * Template Name: Shop **/ $posts_per_row = -1; $po

我需要在wordpress中显示按字母顺序分页的姓名列表

例如。。。。当选择B时

ABcd…X Y Z

巴希尔|巴斯蒂安|贝尔塔|比利|比诺

当我点击A时,我只需要以A开头的名字

我找到了这个密码。。。但是它创建了完整的列表


我需要所有字母都显示为B C D。。。。。X Y Z。。。。。。。。。。。只显示选择了起始字母的名称…

可能不是最好的方法,尽管我就是这样做的

<?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>

也许不是最好的方法,尽管我就是这样做的

<?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>


我建议您查看字母分页脚本,它在任何地方都很容易使用。谢谢,这已经足够好了,也许用WP_QueryI重写吧。我会建议你检查一下字母分页的脚本,它在任何地方都很容易使用。谢谢,这足够好了,可能用WP\u查询重写