• parmendil

    (@parmendil)


    Is there a way to get the get_previous_post() with the menu_order in the sort? I’m using postMash plugin to sort my posts but the get_previous_post() and get_next_post() doesn’t give me the right sort order.

Viewing 1 replies (of 1 total)
  • Thread Starter parmendil

    (@parmendil)

    Ok, I made a function to provide this. If somebody searches for this topic, here you have:

    function bring_previous_next_post_link($previous, $template, $text, $cat) {
    		global $post;
    
    		$original_post = $post;
    
    		query_posts($cat);
    	 	$posts = get_posts('offset=0&orderby=menu_order&order=ASC&numberposts=1000');
    		$link = '';
    
    		$gotThere = false;
    		foreach($posts as $post) {
    			start_wp();
    			if ($post->ID == $original_post->ID) {
    				$gotThere = true;
    			} else {
    
    				if ($previous && $gotThere) break;
    
    				$link = get_permalink(); 
    
    				if (!$previous && $gotThere) continue;
    			}
    		}
    		echo str_replace("%link", "<a href='".$link."'>".$text."</a>", $template);
    		$post = $original_post;
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘get_previous_post get_next_post in menu order’ is closed to new replies.