Viewing 3 replies - 1 through 3 (of 3 total)
  • maybe this can help:
    https://www.transformationpowertools.com/wordpress/continuous-post-numbers
    also read through the comments for how to reverse the numbering with the latest post starting with number 1

    Thread Starter Sparanoid

    (@sparanoid)

    Thanks a lot, but this only works in normal post query. I mean, if it’s in a posts list of specified tag or category, the numbers are still messed up.

    As apposed to going through the Post ID’s, why don’t you collect all the posts in an array, then go through the array? Or does it require a query, thus requiring the actual ID stored in the database?

    If not…

    Reference this:
    https://codex.www.ads-software.com/The_Loop

    I had trouble doing it without messing up the original loop (although there are better fixes)
    Here’s mine:

    $newposts = get_posts('numberposts=-1&category=1');
     	//get all posts (no limit) in new category (look up function in codex for full explination
    
    $maxnew = count($newposts);	// count # posts in array
    
    for($q=0;$q<$maxnew;$q++){    // Loop through posts array
    	$newpostsid[$q] = $newposts[$q]->ID;
                              // assign post ID's to new array
    	echo $newpostsid[$q] . " ";
    //Just double check that it increments all the way through, the # of posts there are.
    
    }

    $newpostsid[$q] will be the current post for each loop.

    Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Increment, continuous post ID’ is closed to new replies.