pagination - Custom post type, next and previous links by page title

I have a site that I am converting to wordpress and have a problem with the next post and previous post, because the def

I have a site that I am converting to wordpress and have a problem with the next post and previous post, because the default value is to sort the posts by date order. However, I want to sort the next "custom post" which is an airfield card, by "name".

When I put all of the airfields into the site, I started off at the beginning, and worked my way along, therefore the first couple of pages of entry's work fine. However, I used a tool to drag in the rest of the information from another database. So now, when I am on airfield "Rufforth", I get the next airfield as "Eddsfield" not "Rougham" which is the next airfield alphabetically by name. My current theme has the following code, please could someone explain how I need to change it to do what I require. I have searched the codex, and various articles and questions, all to no avail.

<?php
    while ( have_posts() ) :
        the_post();
        the_content();
            // If comments are open or we have at least one comment, load up the comment template
        if ( comments_open() || '0' != get_comments_number() ) :
            comments_template();
            endif;


        /********** the new inserted sort function *********/

        function filter_next_post_sort($sort) {
          if (get_post_type($post) == 'airfield_card') {
            $sort = "ORDER BY p.post_title ASC LIMIT 1";
          } else {
            $sort = "ORDER BY p.post_date ASC LIMIT 1";
          }
          return $sort;
        }


        /************* end of sort function ***********/


        the_post_navigation(
            array(
                'next_text' => '<span class="post-title">%title <i class="fa fa-chevron-right"></i></span>',
                'prev_text' => '<i class="fa fa-chevron-left"></i> <span class="post-title">%title</span>',
            )
        );

    endwhile; // end of the loop.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745367676a4624655.html

相关推荐

  • pagination - Custom post type, next and previous links by page title

    I have a site that I am converting to wordpress and have a problem with the next post and previous post, because the def

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信