Well, I've spent all day hacking at it, and although I've gotten closer, I'm feeling that this is more trouble than it's worth. For one, establishing the
foreach loop disrupts the functioning of the default in-Loop tags, such as
the_permalink. While I found substitutes for some of these using array queries, the result is moving further and further away from manageability. Further, this is all occurring on a custom category template, so the pagination and other features are getting disrupted.
Although it was a noble technical challenge, for what I'm doing it's truly not worth going further unless another avenue opens up.
To give some background, I'm doing a "library" page, which basically has reviews of books I've read. For each post, I put the book author's name in a custom field called 'bookauth' -- obviously the default
author_name field value is me, as the author of the post. I was trying to sort by the book author.
Perhaps there is a way within the Loop to temporarily replace the value of the default
author_name field with the value of the custom 'bookauth' field. Then the
query_posts function could be used to sort by
author_name. Seems sneaky, but hey -- I'm surprised what I'm asking to do isn't easier in the first place!
Thank you once again for your suggestions. I've definitely learned a lot about arrays and queries in the process, and haven't lost hope for a working solution...