简体   繁体   中英

How to fix the previous/next links, when rearranging the order of WordPress posts

I am rearranging the posts in a WordPress blog. I mostly write "backwards" (in the blog world) and wish the newest material to appear at the bottom and the posts I wrote first, at the top.

I drag the posts, using the plug-in Advanced Post Types Order (even the paid version). That works fine. But one small detail remains: The previous/next links get the wrong content (mostly the content has switched places. (There is an option in the plug-in related to previous/next links, but for me it doesn't make a difference.)

I am not even sure I am in the right page. I don't think the page is cached since it changes content often?

 // Previous/next page navigation.
 the_posts_pagination( array(
 // 'prev_text'          => __( 'Previous page', 'twentyfourteen' ),
 // 'next_text'          => __( 'Next page', 'twentyfourteen' ),
 'next_text'          => __( 'Previous page', 'twentyfourteen' ),
 'prev_text'          => __( 'Next page', 'twentyfourteen' ),
 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfourteen' ) . ' </span>',
 ) );

I know basic PHP but I am not clear over what this does (except filling the array). I am just experimenting and I am not sure this will end well.

Can someone please give advice how I can switch back the content of the links under "Previous" and "Next".

Thanks

I give top rating to the NSP support team (the constructors of the Post Types Order plug-in), they sent me the necessary information:

The file to edit is single.php

// Original code:
// Previous/next post navigation.
the_post_navigation( array(
'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'twentyfourteen' ) . '</span> ' .
'<span class="screen-reader-text">' . __( 'Next post:', 'twentyfourteen' ) . '</span> ' .
'<span class="post-title">%title</span>',
'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'twentyfourteen' ) . '</span> ' .
'<span class="screen-reader-text">' . __( 'Previous post:', 'twentyfourteen' ) . '</span> ' .
'<span class="post-title">%title</span>',
) );

To modify the code can change the link headers properly but they still appear in the wrong order:

// Previous/next post navigation.
the_post_navigation( array(
'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'twentyfourteen' ) . '</span> ' .
'<span class="screen-reader-text">' . __( 'Next post:', 'twentyfourteen' ) . '</span> ' .
'<span class="post-title">%title</span>',
'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'twentyfourteen' ) . '</span> ' .
'<span class="screen-reader-text">' . __( 'Previous post:', 'twentyfourteen' ) . '</span> ' .
'<span class="post-title">%title</span>',
) );

Using code supplied from NSP you can print the links in any order or formatting.

$args   =   array(
'sort_id'   =>  25,
'taxonomy'  =>  'features',
'term_id'   =>  10
);
next_post_type_link( '%link', __( '<span class="meta-nav">Previous Post: </span> %title', 'twentyfourteen' ), $args );
echo "<br>";
$args   =   array(
'sort_id'   =>  25,
'taxonomy'  =>  'features',
'term_id'   =>  10
);
previous_post_type_link( '%link', __( '<span class="meta-nav">Next Post: </span> %title', 'twentyfourteen' ), $args );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM