show previous/next post orderer by title in custom post types

If you use a filter like the following to adjust the order of a post type archive, then the next & previous links will work perfectly without need for modification: function wpse_139866_set_order_by( $wp_query ) { if ( ! is_admin() && $wp_query->is_post_type_archive( ‘my_post_type’ ) && $wp_query->is_main_query() ) { $wp_query->set( ‘orderby’, ‘title’ ); } } add_action( ‘pre_get_posts’, … Read more

How do I use the add_query_arg function in a template tag like previous_post_link?

previous_post_link and its sibling are pretty simple functions, so there’s not a lot to play with if you really want to use these (if you’re building a plugin and do not want to touch the theme, making you need a filter which isn’t there). However, since you’re talking about templates, I’m guessing that you’re building … Read more

Navigate to external link if last page or post in a category

Since it’s not clear exactly what you need it’s hard to give you the best solution. However … You should be able to use get_next_posts_link() in your loop template. Or get_previous_posts_link() if that’s what you want. If that returns null you can then echo a link to whereever you want in your template. if(!get_next_posts_link()) { … Read more

I need to customize wordpress “previous” “next” links

If I’m understanding this correctly, you may just want to use something like: $prev = get_previous_post(); $next = get_next_post(); Then to access the title you’d do something like <h1><?php echo $prev->post_title ?></h1> And if you wanted its image: $prev_img = get_post_thumbnail_id( $prev->ID ); <img src=”https://wordpress.stackexchange.com/questions/248644/<?php echo $prev_img; ?>” alt=”your alt here”>