WordPress Post # of # filtered by category slug

You should use one of query functions – get_posts(), it allows to very flexibly configure set of posts to retrieve.