title: Assign a number to each post in a custom post type?
body: <p>I'm building a page that is displaying a list of posts (potentially they will be randomly displayed) in a grid. </p>
  
  <p>These posts are a custom post type, and each post is assigned to a single taxonomy for organization.</p>
  
  <p>For each post I'd like to display an associated number. I don't mean the post ID, as that isn't specific enough. Basically, I'd like to treat the custom post type as its own list of posts. So the first post in that post type will be post #1, the second would be #2, and so on.</p>
  
  <p>As well, if it's possible to do this by taxonomy, that would be even better. But I'd settle for just numbering the posts in the custom post type in general.</p>
  
  <p>My solution so far is this: create a function in functions.php that loops through the custom post type, and assigns a number (starting at 1 for the first post) to each post as a custom field. This function runs whenever the page that displays the posts is loaded. So that function runs first in its own loop, and then the page does a normal loop and gets each number.</p>
  
  <p>This solution works cosmetically. I'm getting the result that I want. However, it's not very efficient as it will run any time the page is loaded.</p>
  
  <p>Is there a better way to do this? Perhaps a way to automatically assign a number to a post whenever a post is published? I understand that if a post is deleted, there'd be a skipped number. That's acceptable.</p>
  
  <p>I hope this is clear. </p>
  
  <p>I edited this for clarity, as well as updating the current solution which has changed. I also removed the block of code I have here because it's no longer necessary.</p>