I'm using the following code to paginate between custom post types and it doesn't seem to be using the meta_key or meta_value_num and I can't figure out why. The CPT is set-up to have hierarchal => true and the Capability type is a page.
This is the code I'm using for paging (which doesn't seem to make a difference--I tried using orderby=menu_order and that didn't work either).
<?php if
(get_adjacent_post(false, '', true))
{ echo previous_post_link('%link' , '<i class="fa fa-chevron-left"></i>'); }
else
{ echo previous_post_link('%link' , '<i class="fa fa-chevron-right"></i>');
$newest_post = get_posts('post_type=employee-bios&posts_per_page=1&order=DESC&meta_key=display-order&orderby=meta_value_num'); $newest_post_id = $newest_post[0]->ID;
echo '<a href="'.get_permalink($newest_post_id).'">
</a>'; }
?>
<?php if
(get_adjacent_post(false, '', false))
{ echo next_post_link('%link' , '<i class="fa fa-chevron-right"></i>'); }
else
{ echo ''; $eldest_post = get_posts('post_type=employee-bios&posts_per_page=1&order=ASC&meta_key=display-order&orderby=meta_value_num'); $eldest_post_id = $eldest_post[0]->ID;
echo '<a href="'.get_permalink($eldest_post_id).'" title="link to '.get_the_title($eldest_post_id).'"><i class="fa fa-chevron-right"></i></a>'; } ;
?>
And this is my WP_Query (which doesn't seem to matter in the scheme of things either--I'd started off just using while have posts and when that didn't work, I tried the WP_Query)
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'employee-bios',
'posts_per_page' => 1,
'orderby' => meta_value_num,
'meta_key' => 'display-order',
'order' => 'ASC',
'paged' => $paged
);
$my_query = new WP_Query( $args );
?>
My client wants to be able to select the order of the employee bios on a landing page and they should paginate in the order they've been placed on the landing page (which is why I tried using both menu_order and a custom field meta value for sorting).
I've also tried changing the Capability type from page to post and that doesn't seem to make a difference either.
Any help would be much appreciated. Thanks!