Get next and prev item from custom WP_Query and Custom Post Type

I want to make a pager for a custom wp_query where I can have a prev and a next. I have a CPT called family and I must show the families that meet the condition that their status is Retained, important I must show only one family per page, and I must put the paginator to navigate one by one. This is my code: $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $args_families = array …
Category: Web

Get previous/next post from (specific) category

I have posts with two categories, for example, 1st post is in category "product" and "shoes", 2nd is in category "product" and "shirts", 3rd is in category "product" and "sport clothes"... So, posts have one mutual category ("product" in this example), and one more specific category. I tried to get previous/next post with: $next_post = get_next_post( true ); $previous_post = get_previous_post( true ); But then, for example on 2nd post I have 1st and 3rd post as previous/next posts, because …
Category: Web

Next and Previous loop

I am making a wordpress site but i need little help, What I have is a function with Next and Previous buttons to list projects, but when i go to the last project the Next button is gone. What I want to do is, when I go to the last project I hit "Next" and direct me to the first project something like loop slide Here is my code: <?php if (has_term( 'type-1', 'projecttype' ) ) { ?> <div class="holder"> …
Category: Web

Next Previous siblings child pages

I tried this piece of code : https://wordpress.stackexchange.com/a/54474/80921 because I couldn't figure out how to get the next and the previous post. But this code won't work now and I'm not able to comment. The error I get is "Undefined offset: -1" when looking for the ID. Here is the full code found on the related page. Thanks for any help ! $pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc"); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_search($post->ID, …
Category: Web

"next page" of parent in infinite loop

I'm trying to include a "Next Service" button on a website that hopefully take you to the next page under the Services page (Parent) so no matter which service you are on, it can loop through to the next (regardless if it's the first or last page). However the code I have does that but when it gets to the last one, it carries on to the next page - regardless of the fact it's not under 'Services'. <?php $nextPost …
Category: Web

Custom post type, next and previous links by page title

I have a site that I am converting to wordpress and have a problem with the next post and previous post, because the default value is to sort the posts by date order. However, I want to sort the next "custom post" which is an airfield card, by "name". When I put all of the airfields into the site, I started off at the beginning, and worked my way along, therefore the first couple of pages of entry's work fine. …
Category: Web

get_adjacent_post() returning weird results

I am using get_adjacent_post() function to display links to a previous and next post. It is a custom post which also has a custom taxonomy. This is the code I am using: $prev = get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if($prev){ $url = get_permalink($prev->ID); echo '<a href="' . $url . '">Previous</a>'; } if($next) { $url = get_permalink($next->ID); echo '<a href="' . $url . '">Next</a>'; } As far as I understand, the parameters in the get_adjecent_post() function should consider …
Category: Web

How to Next and Prevous Navigation Buttons on the end of the page with custom image Using Wp Post Navigation Plugin

I am New to Wordpress and Don't know Coding hecnce on my website i have two section one for blog and other is episodes with seperate catageory and to navigate between the post in same catageory, So Iam Using This Plugin Called Wp Post Navigation by Anas Mir.It me Working Fine For me for the cattageoris in which Iam i Want to Navigate in Episode Posts as Ihave Changed the Imgae of Previous and Next Episode Button with Text as …
Category: Web

Get Next / Prev 3 Posts in Relation to Current Post

I have 7 posts, like this: 1 2 3 4 - this is the current post 5 6 7 As noted, number four is the current post being displayed. I need to create a query that will allow me to display the previous 3 posts (by publication date) and also the three posts after. This can be done with two separate queries. I've been able to display the immediately previous or next post, just not the ones further down / …
Category: Web

Wordpress template next_prev

I have next and prev with a gallery and the select is not ok and I have no idea how to change. I want to make the select by two category not by a status (publish) function in_conference_prev_next_posts() { $cmsmasters_post_type = get_post_type(); $published_posts = wp_count_posts($cmsmasters_post_type)->publish; if ($published_posts > 1) { echo '<aside class="post_nav">'; previous_post_link('<span class="cmsmasters_prev_post">%link<span class="cmsmasters_prev_arrow"><span></span></span><span class="sub">previous</span></span>'); next_post_link('<span class="cmsmasters_next_post">%link<span class="cmsmasters_next_arrow"><span></span></span><span class="sub">next</span></span>'); echo '</aside>'; } }
Category: Web

Add a "Next Post" & "Previous Post" styled button manually to a post

Can anyone walk me through the exact steps? I want to create two buttons that sit next to each other at the bottom of a post for the NEXT and PREVIOUS posts...I want to be able to insert this manually (html), and using a style/class to do it. I'm assuming I have to do something in the functions.php file first? Then create a custom CSS button? Then add the code in the bottom of my post?
Category: Web

Wordpress The Next Posts

So for previous and next posts I used this from wordpress codex <div class="navigation"> <p> <?php posts_nav_link('∞','Go Forward In Time','Go Back in Time'); ?> </p> </div> I want to change that.. in the wp-admin, I used on settings -> reading -> Blog pages show at most = 5 so I wanted to have a button to click on and load like 5 more posts, every time you click on the button and you are on the bottom of the page …
Category: Web

Display NEXT and PREVIOUS pagination?

I need help on the pagination. I try to put the NEXT and PREVIOUS pagination that show the post in a same category, but I am not sure what happen that showing nothing. If you can help, much thanks! <div class="row"> <div class="page"> <?php $previous_post = get_previous_post('%link', 'Next post in category', TRUE); if ( $previous_post ) : ?> <!-- [ PREVIOUS ITEM ]--> <div class="col-xs-6"> <?php if ( has_post_thumbnail( $previous_post->ID ) ) : ?> <?php echo get_the_post_thumbnail( $previous_post->ID, 'gallery-navigation' ); …
Category: Web

How can I change the prev / next buttons text to Dutch?

If you look to this page everything is alright except the previous and next buttons text are in English. Does anyone know how I can make them display in Dutch? I already tried to change them but no luck. NB: I'm using Contango theme. The function looks like this : /** Contango Link Pages */ function contango_link_pages() { $contango_options = contango_get_settings(); if( $contango_options['contango_post_style'] != 'excerpt' ) { return wp_link_pages( array( 'before' => '<div class="page-link"><span class="assistive-text">'. __( 'Pages:', 'contango' ) .'</span>', …
Category: Web

Category foreach Paging

I'm using the following code to display categories on my homepage, what I'd like to do is add the ability for paging with previous and next links, I haven't been able to figure out how to do this with a foreach can anyone point me in the right direction? Original Code: <?php $cat = get_cat_ID("Photos"); $categories = get_categories("child_of=$cat"); ?> <?php if (is_array($categories) && count($categories) > 0) : ?> <?php foreach ($categories as $category) { ?> <?php query_posts("cat=$category->cat_ID&orderby=rand&posts_per_page=1"); ?> <?php while …
Category: Web

Loop - how to get previous/next post for first/last post?

I have a simple loop for a JS slider, I want to display previous and next posts titles on my slide, but I can't get previous post title on the first slide (because apparently first post have no previous posts): $prev_post = $loop->posts[$loop->current_post - 1]; // ALWAYS NULL FOR FIRST POST :( $next_post = $loop->posts[$loop->current_post + 1]; // ALWAYS NULL FOR THE LAST POST echo $next_post->post_title; echo $next_post->post_title; Is there any easy way to fix that?
Category: Web

Add next and previous post links on pages like category, tags or archive pages

I am trying to find a solution for getting next pages for category or tag page in WordPress, tried with next_posts_link and previous_posts_link in these pages, but it's not working. Same functions are working on post listing page for me Below is my code <div class="wrapper inner_content_wrap"> <?php next_posts_link( '<span class="label iconfont"><img src="'.get_template_directory_uri().'/images/pager_arw.png" alt=""></span><span class="entry-info-wrap">Next Entries</span>',3); ?> <?php previous_posts_link( '<span class="label iconfont"><img src="'.get_template_directory_uri().'/images/pager_arw2.png" alt=""></span><span class="entry-info-wrap">previous Entries</span>'); ?> <div class="blog_area"> <div class="container"> <?php if(have_posts()) : $paged = ( get_query_var( 'paged' ) …
Category: Web

Add title for previous and next posts to Yoko Theme

Help! I want to change my "Previous" and "Next" post links to use the actual post titles. I have done all kinds of online research and code manipulation without any success. I am using the Yoko theme. Here is my current single.php code. What do I need to update it to be? My website is www.thelawstudentswife.com <div id="content"> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'single' ); ?> <?php comments_template( '', true …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.