Community Forums › Forums › Archived Forums › Design Tips and Tricks › Navigation on CPT with manual sort?
- This topic has 3 replies, 2 voices, and was last updated 7 years, 6 months ago by brettatkin.
-
AuthorPosts
-
October 11, 2016 at 5:56 am #194497PrecisiMember
Hi everyone, I'm a little stuck on something I'm trying to do. Any help or links pointing me in the right direction would be appreciated.
I'm using this trick to get navigation working on my CPT, and it's working fine. https://wpbeaches.com/add-custom-post-type-navigation-links-in-genesis/
However, I can't figure out how to have that navigation work via my manual sorting method. (I want it to sort by a field I've added in ACF).
The CPT is for 'pages' in a book, and then I have it sorted by chapter and volume, so I'd like it to be able to go from page to page with prev/next based on the manually entered ###-###-### (volume-chapter-page) for each entry on the 'pages' CPT.Thank you!
October 11, 2016 at 4:26 pm #194546brettatkinMemberNot sure if this will help (it is alternative to what you asked), but I just did something similar where I added pagination for a CPT based on the custom taxonomy. Here is my code:
add_action( 'genesis_entry_footer', 'dr_work_prev_next_post_nav_cpt' ); function dr_work_prev_next_post_nav_cpt() { if ( ! is_singular( array( 'work', 'post' ) ) ) //add your CPT name to the array return; genesis_markup( array( 'html5' => '<div %s>', 'xhtml' => '<div class="navigation">', 'context' => 'adjacent-entry-pagination', ) ); echo '<div class="pagination-previous alignleft">'; previous_post_link( '%link', 'Previous Project', TRUE, '', 'work-type' ); echo '</div>'; echo '<div class="pagination-next alignright">'; next_post_link( '%link', 'Next Project', TRUE, '', 'work-type' ); echo '</div>'; echo '</div>'; }
In this line (previous_post_link( '%link', 'Previous Project', TRUE, '', 'work-type' );), work-type is the name of my custom taxonomy. What happens is that the pagination works just for items that have the same taxonomy value.
So, you could try creating a custom taxonomy for the CPT, create values for each book. Then for each page, assign it that book value and order the posts accordingly.
October 11, 2016 at 4:37 pm #194547PrecisiMemberThanks for the suggestion. I'm not sure this would work though. The user needs to be able to go through the pages in order, chapter to chapter, book to book (It's for a web comic) so that's why I came up with the method of using a custom field with the numbering. If I split it out based on the taxonomy, it wouldn't move to the next set of pages seamlessly, right?
October 12, 2016 at 11:14 am #194593brettatkinMemberNot sure what you mean by seamlessly. Here is an example on a site I'm still working on.
See the next/previous at the bottom of the page. You can paginate through all five employees. Each employee is a post (a CPT).
I'm doing the same thing in another section that paginates through posts, but limited to the taxonomy term for that post.
If each book page is a post with a taxonomy of "book 1", they should be able to page through the posts. The only time consuming piece would be getting the pages in order.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.