Articles of previous post link

Pagination for custom loop on custom page template is not displaying anything

I have created a page where user can see his favourite post which has been bookmarked by him get_user_favorites($user_id); This function is responsible for returning me all the favourite posts bookmarked by user in an array. I am using this approach to get the data from the database and make it work inside my Custom […]

Tweak next_post_link for it to include thumbnail

I am using a fork from underscores.io, and there is this code: next_post_link( ‘<div class=”nav-next”>%link</div>’, _x( ‘%title <span class=”meta-nav”>&rarr;</span>’, ‘Next post link’, ‘nicosite’ ) ); Wich prints the next post link, How Can I use it (or alternatives) to include the post’s thumbnail? -edit- Right now, I have next_post_link( ‘<div class=”nav-next”>%link</div>’, _x( ‘%title <span class=”meta-nav”>&rarr;</span>’, […]

Get ID for previous/next image link

For grabbing previous or next image link on attachment page we can use this https://codex.wordpress.org/Function_Reference/previous_image_link How do we get ID for that attachment? Because I would like to get its alt title by using this echo get_post_meta(get_the_ID(), ‘_wp_attachment_image_alt’, true); and put it below image, with maybe also a few more stuff.

Get next post in same category not working WP 4.7.4

I have posts which assigned 1 of 2 different categories. On the single post view i want to show a next and previous link of posts with the SAME category. This should be straightforward, i’ve tried using get_previous_post etc but i cannot exclude posts assigned to the other category. I’ve tried $prevPost = get_adjacent_post(TRUE,’129′,TRUE); where […]

Disable “previous link” in first post and “next link” in last post

how can I disable “previous link” in first post and “next link” in last post? thank you

Making next_posts_link(); return posts by month

I’m building a site for a magazine using WP and am needing to display a month of posts at a time. How would I make the next_posts_link(); and previous_posts_link(); functions return results, shorted as one month per page? If I can’t do it via those functions, how would I make the front page display in […]

next_post_link / previous_post_link not working with WP_Query

I am trying to add next and previous page buttons to my template, but when I try to use either next_post_link or previous_post_link, it just does not work. Could it be because I am using WP_Query? Here is my code thus far, <?php get_header(); ?> <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; ?> <?php […]

query_posts pagination will always show identical content

Anyone here see why my pagination won’t work? I can get “previous page” to show up, but when navigating to “page-2”, the content will stay identical to the content on “page-1”. <?php /* Template Name: Generic Trips Template */ ?> <?php get_header(); ?> <?php get_template_part( “beforeloop”, “page” ) ?> <?php $types = $post->post_name; ?> <?php […]

Add Previous/Next Buttons to CPT Single Pages Only

I’m working with a site that is displaying a portfolio CPT on the home page in a “Grid Loop.” On the single pages, i’d like to add Previous & Next Item buttons. I thus added this code: function custom_post_navigation() { ?> <div class=”prev_next”> <div class=”nav_left”> <span class=”prev”><?php previous_post_link(‘%link’, ‘Previous Item</span>’); ?> </div class=”nav_right”> <div> <span […]

Why are previous_post_link/next_post_link skipping some posts?

I have a single page template for one of my custom post types. Are the top of this page I have… <?php previous_post_link(‘%link’, ‘Prev Project’); ?> <?php next_post_link(‘%link’, ‘Next Project’); ?> These links seem to skip some posts, but not all of them. Any idea?