Using previous_post_link and next_post_link to wrap around post sequence

Add following custom functions in functions.php file and instead of calling previous_post_link and next_post_link functions call custom_next_post_link and custom_previous_post_link custom functions respectively. function custom_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories=””, $previous = true ) { if ( $previous && is_attachment() ) $post = get_post( get_post()->post_parent ); else $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); if … Read more

adding custom fields to next and previous post link

Here’s the code for what you’re trying to do (accessing post custom value): <?php global $post; $prev_post = get_adjacent_post(); $next_post = get_adjacent_post( false, ”, false ); $prev_post_id = $prev_post->ID; $next_post_id = $next_post->ID; // this should, according to your code above, be the http://example.com/your/img.jpg string $prev_img_path = get_post_custom_values( ‘your_key_name’, $prev_post_id ); $next_img_path = get_post_custom_values( ‘your_key_name’, $next_post_id … Read more

Next and previous link in custom post type in the same taxonomy term

previous_post_link() and next_post_link() work perfectly with custom post types. You need to paste this code in your single-customposttype.php (which in your case is single-portfolio.php): <div class=”previous-post-link”> <?php previous_post_link(‘%link’, ‘<< Previous Post’, $in_same_term = true, $excluded_terms=””, $taxonomy = ‘the-custom-taxonomy-associated-with-your-custom-post-type’); ?> </div> <div class=”next-post-link”> <?php next_post_link(‘%link’, ‘Next Post >>’, $in_same_term = true, $excluded_terms=””, $taxonomy = ‘the-custom-taxonomy-associated-with-your-custom-post-type’); ?> … Read more

Why is previous_post_link and next_post_link working outside of the Loop?

“Inside the Loop” essentially means that function relies on data from global variables (such as $post) that are set up when Loop runs. Note that this is not necessarily done by main Loop of query_posts(). In your specific code those variables are filled by $custom_posts->the_post() calls and after that wp_reset_query() gets those values back to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)