We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

4

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>' ); ?> ...


3

This can be done much better with the date_query property of WP_Query class. This will get the posts before the publish date of the current post // WP_Query arguments $args = array ( 'post_type' => 'post', 'post_status' => 'publish', 'date_query' => array( 'column' => 'post_date', 'before' ...


3

You can loop the slides quite simply: $prev_index = ( $loop->current_post == 0 ) ? count( $loop->posts ) - 1 : $loop->current_post - 1; $next_index = ( $loop->current_post == count( $loop->posts ) - 1 ) ? 0 : $loop->current_post + 1; $prev_post = $loop->posts[ $prev_index ]; $next_post = $loop->posts[ $next_index ]; echo $next_post-...


3

Pass Paged into parameter array of query_posts You should set get_query_var( 'paged' ); if you want your query to work with pagination. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args_news= array( 'cat' => 1, 'posts_per_page' => 2, 'orderby' => 'post_date', 'order' => 'DESC', '...


3

1) Move the function to the functions.php file, that's where it belongs. Put it at the end before any closing ?>: function my_theme_navigation() { global $shortname; if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next' ) : // the block for next-prev navigation previous_posts_link ('Newer'); ...


2

Your theme's body_class can be used to target specific pages: body.home /* front and subsequent pages */ body.paged /* any page *except* front page */


2

I figured it out! After a lot of research and trial and error, I managed to figure out how to get the paging to work for both versions...my original code and the simplified code update. Original Code Solution: <?php $cat = get_cat_ID("Photos"); $categories = get_categories("child_of=$cat"); $limit = 9; $total = count($categories); ...


2

You have to loop through that part of the code to get more posts: $args = array( 'posts_per_page' => -1 ); $the_query = new WP_Query( $args ); <?php if ($the_query->have_posts()) : ?> <?php while ($the_query->have_posts()) : $the_query->the_post(); ?> ...<your code>... <?php endwhile; ?> <?php endif;...


1

You both have to use the paged query var for the loop, and the max_num_pages var for the links: $news_args = array( 'cat' => 1, 'paged' => get_query_var('paged'), 'posts_per_page' => 1, 'orderby' => 'post_date', 'order' => 'DESC', ); $news_query = new WP_Query($news_args); if ($news_query->have_posts()) : while ($...


1

Two problems I can see off hand here Firstly, you should move your query to outside your if conditional statement. Secondly, when using WP_Query, the $max_pages parameter should be used when using next_posts_link( $label , $max_pages ); So, your code should look something like this <div class="wrapper inner_content_wrap"> <?php ...


1

If you're simply using one language on your site: Find the utility.php file in your themes folder with location lib/functions/utility.php Next find the lines 227 and 231 and change the __( 'Previous Post', 'contango' ) and __( 'Next Post', 'contango' ) to your desired values. For example: previous_post_link( '%link', __( 'vorige post', 'contango' ) . ' <...


1

Hmmmm, the solution to this problem was to read the details of the plugin. It has the capability of returning values other than a link to the next post - this includes the ID of the Next and Previous Post. In case anyone else reads this in the future and wants to see how to get the ID all you have to do is something like: <?php $link=next_post_link_plus(...


1

Easily enough: <nav id="nav-below"> <div class="nav-previous"><?php previous_post_link(); ?></div> <div class="nav-next"><?php next_post_link(); ?></div> </nav><!-- end nav-below --> The previous_post_link() and next_post_link functions return a link which text is the title of ...


1

straight from the Codex; example: <div class="nav-previous"><?php previous_post_link( '%link', '&larr; %title' ); ?></div> <div class="nav-next"><?php next_post_link( '%link', '%title &rarr;' ); ?></div>


1

Try this, nice and simple: <?php next_post('%', 'Prev: ', 'yes'); ?> <?php previous_post('%', 'Next: ', 'yes'); ?>


1

This one is not a good way to do it but it's easy to implement global $post; $original = $post; $next = get_next_post(true); $prev = get_previous_post(true); $post = $next; next_post_link(); $post = $original; next_post_link(); // display current post previous_post_link(); $post = $prev; previous_post_link(); $post = $original; To make the code more ...


1

The function WordPress ultimately uses for this is get_adjacent_post(), which has filters that allow you to modify the query directly. You'd have to modify the JOIN, WHERE and ORDER BY clauses to join the post meta table and order by your custom field. Another option is the Ambrosite Next/Previous Post Link Plus plugin.


1

get_previous_post uses get_adjacent_post() which has a bunch of filter hooks you can use but a much simpler approach would be to create your own function, something like this: // Create a new filtering function that will add our where clause to the query function date_filter_where( $where = '' ) { global $post; $where .= " AND post_date >= '".$...


Only top voted, non community-wiki answers of a minimum length are eligible