Show category from “Next post” and “Previous post” [edited]
Show category from “Next post” and “Previous post” [edited]
Show category from “Next post” and “Previous post” [edited]
So I can’t give you a complete solution but here are the pieces that I think might help: Getting parent post ID: wp_get_post_parent_id() – https://developer.wordpress.org/reference/functions/wp_get_post_parent_id/ Getting all posts with a particular parent ID. Here’s a WP_Query args to get all posts by parent ID $args = array( ‘post_parent’ => $parentID, ‘posts_per_page’ => -1, ‘orderby’ => … Read more
Are you using ‘posts_per_page’ and ‘paged’ in the query string? if not try to add $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $query .= ‘posts_per_page=5&paged=’.$paged Number 5 will be replaced with the number of posts after which you want the next page (pagination) link to show up. Also remove the if statement on the next … Read more
Haven’t checked the plugin you mention… but I use this solution for doing an “author” navigation. I adjusted the functions and this should probably work without the plugin (untested). You need to adjust the ID, and the conditions itself if you want more exclusions. [edit: corrected functions, the queries were missing the menu_order condition] notes: … Read more
Well, yes, of course. Take a look at this reference: http://codex.wordpress.org/Function_Reference/previous_post_link http://codex.wordpress.org/Function_Reference/next_post_link You can customize it however you like, so you can simply put an html image tag in there. The function must be used in the loop to work. I’d do it like this: <?php previous_post_link(‘%link’, ‘<img src=”https://wordpress.stackexchange.com/questions/141544/Image URL” width=”20″ height=”20″ alt=”%title” />’); ?> … Read more
Use the 4th parameter $excluded_terms http://codex.wordpress.org/Function_Reference/next_post_link <?php next_post_link( $format, $next, $in_same_term = true, $excluded_terms=”402″, $taxonomy = ‘category’ ); ?> Same for the previous_post_link http://codex.wordpress.org/Template_Tags/previous_post_link $previous=”<span class=”meta-nav”>Previous Post</span>”; $next=”<span class=”meta-nav”>Next Post</span>”; <?php previous_post_link( $format, $previous, $in_same_term = true, $excluded_terms=”402″, $taxonomy = ‘category’ ); ?> Or you could create a template tag like whats included in Twenty … Read more
As I previously said in a comment You are using invalid values in get_previous_post() and get_next_post(). You are better of here writing your own function I came up with the following. : Get an array of all the posts and determine the current post’s position. Get the post ID’s of the posts on both sides … Read more
@Milo solved this one – It was because the posts were imported using an import plugin hence having all the same date bar a few that ticked over every second! All posts must have a unique date / time in order for next and prev links to work.
You want to change the in_same_term value to TRUE as follows: function crunchify_post_navigation(){ ?> <div class=”arrowNav”> <div class=”arrowLeft”> <?php previous_post_link(‘%link’, ‘↞’, TRUE); ?> </div> <div class=”arrowRight”> <?php next_post_link(‘%link’, ‘↠’, TRUE); ?> </div> </div> <?php } add_action(‘wp_footer’, ‘crunchify_post_navigation’);
Take a look at the get_adjacent_post function. It takes three paramters, all of which are optional: a boolean, whether the post should be from the same category a string of category IDs that should be excluded a boolean, whether the previous (true) or next (false) post should be retrieved. Hence the previous post, regardless of … Read more