previous next with custom-post-type by order attribute

I have a custom-post-type called 'artists'. I list them by the order attribute (menu_order).

$args = array(
    'post_status' = 'publish',
    'post_type'   = array('artists),
    'orderby'= array('menu_order'='ASC' ),
);
$wp_query = new WP_Query( $args );

When I use the_post_navigation() to get the previous and next links, it takes the date as the order instead of the menu_order. How can I get it to work right in this case?

Topic menu-order previous-post-link Wordpress

Category Web


Maybe this function is better to use get_adjacent_post.

I have not tested it yet but it seems to more flexible than the_post_navigation() function.

FYI, the_post_navigation() uses this function internally to retrieve the next and previous posts.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.