Posts archive index pagination in a static page custom query

When you perform a custom query such as this one, you have to do a bit of a “hack” to get pagination to work properly. Change this: <?php query_posts( “category_name=news&orderby=date&order=ASC&posts_per_page=2” ); ?> …to a WP_Query call: <?php $news_query = new WP_Query( “category_name=news&orderby=date&order=ASC&posts_per_page=2” ); ?> And then you need to *move your custom query object into … Read more

How to make Next and Previous attached image navigation on the attachment page? [duplicate]

Use previous_image_link and next_image_link in a image.php or attachment.php file. <nav id=”image-navigation” class=”navigation image-navigation”> <div class=”nav-links”> <?php previous_image_link( false, ‘<div class=”previous-image”>’ . __( ‘Previous Image’, ‘$text_domain’ ) . ‘</div>’ ); ?> <?php next_image_link( false, ‘<div class=”next-image”>’ . __( ‘Next Image’, ‘$text_domain’ ) . ‘</div>’ ); ?> </div><!– .nav-links –> </nav><!– #image-navigation –> Source: Twenty Fourteen

Get next/previous cousin page

I solved this by getting all pages, assigning them by level, and then getting the next page of the same level. If you also want the previous page then you should probably cache the functionality that groups the pages by level. function wpse16875_next_page_same_level_link() { $next_page_same_level = wpse16875_next_page_same_level(); if ( $next_page_same_level ) { return ‘<a href=”‘ … Read more