Shortcode Next Previous page not following ID order
-
Hi
I would be so grateful if someone could help me. I really don’t understand why this is bugging. I have added a function to create a shortcode that enables me to go to previous and next page within a smae category. It worked perfectly for 3 categories but on other it doesn’t follwo the ID order. I changed all dates of pages to exactly same just in case that influenced but nothing. I use Elementor to do pages so i thought it was based on order of when I created the pages but again that didn’t apply. I thought it may be alphabetic but still not.
Anyways If you could help me in adding to my existing function the requirement to follow by ID order within the same category i would be so grateful.Here is my code:
// next
add_shortcode( ‘prev’, ‘prev_shortcode’ );
add_shortcode( ‘next’, ‘next_shortcode’ );
function next_shortcode($atts) {
global $post;
ob_start();
next_post_link( ‘<div class=”nav-next”>%link</div>’, ‘
‘, ‘%title <span class=”meta-nav”>’ . _x( ‘→’, ‘Previous post link’, ‘morphology’ ) . ‘</span>’,
true);
$result = ob_get_contents();
ob_end_clean();
return $result;
}function prev_shortcode($atts) {
global $post;
ob_start();
previous_post_link( ‘<div class=”nav-previous”>%link</div>’, ‘
‘, ‘%title <span class=”meta-nav”>’ . _x( ‘→’, ‘Previous post link’, ‘morphology’ ) . ‘</span>’,
true );
$result = ob_get_contents();
ob_end_clean();
return $result;
}My website is somaliforkids.com tan example of my problem is this category:
the animals are meant to follow the order as slider shows below but it goes randomly… despite having order ID correct, categories correct, date published same…Thank you so much for your help
Isabelle -
Your site is not hosted with WordPress.com. It is a site using the open-source WordPress software (from WordPress.org) but hosted with Bluehost.
Because WordPress.com and WordPress.org are two entirely separate entities, we cannot access files or data for sites that are hosted elsewhere, so WordPress.com staff can only assist with sites that are hosted on our servers. You can find more information here about the differences between WordPress.org software and WordPress.com: https://wordpress.com/support/com-vs-org/
https://wordpress.org/support/ is a great resource for sites using the open source WordPress.org software, and you can find support for that at: https://wordpress.org/support/forums/
Your hosting provider’s support team may also be able to assist.
- The topic ‘Shortcode Next Previous page not following ID order’ is closed to new replies.