• Hi,

    I write a plugin that converts categories, authors, and pages into subdomains (https://webdev.casualgenius.com/projects/wordpress-subdomains/). I need to grab the post IDs of all the posts that belong to a category (or author) and it’s sub categories.

    I’m currently using get_posts to do this. However I seem to have a number of users with hundreds or thousands of posts in one category and this function then uses up the php memory allocation with the amount of data being fetched. This seems a bit of a problem when all I want are the post IDs.

    I looked at the source for get_posts and it seems it wont just get the IDs for me. I looked, but couldn’t find a function that will do what I want.

    I did originally use my own SQL, but moved to get_posts because I thought it was a better way of doing things. Does anyone know of a function that will get me just the Post IDs or of a way of doing this without reverting to custom SQL? It does seem a little strange that I can’t find a wordpress function that does it. If I’m being a blind fool please let me know.

    Regards,

    Alex

  • The topic ‘Get post IDs for a category or author’ is closed to new replies.