Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter abrupt219

    (@abrupt219)

    Oh, and by the way, the page in question can be enjoyed here.

    Thread Starter abrupt219

    (@abrupt219)

    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…

    Thread Starter abrupt219

    (@abrupt219)

    Viper007Bond, thanks for the input. I’ve been playing with the above suggestion, but it’s not exactly working. It seems that nesting the foreach loop inside (or outside) the Loop is resulting in way to many iterations. The page in question is just a list of post titles and custom field values, and what I’m getting is about 20 copies of each post’s custom field value, without the title or other post data.

    I’ve tried changing the placement of the foreach statement, and even removing the original Loop function with various incomplete results. Where would you place your code in relation to the Loop?

    Perhaps your proposal for the “long version” is needed — where the custom post ordering is read into an array in the beginning, then passed to the Loop for normal processing. This would seem to reduce the amount of querying going on, as you said, and might be more logically modular (ie create the query array, then process it).

    I should note that I’m teaching myself php and MySQL as I go along here, with no formal training. So I’m not really a newbie but certainly not an expert. I understand what your code above is attempting to do, but not quite why it’s not working…

    Anyway, thanks for having a go at this one,

    abrupt219

Viewing 3 replies - 1 through 3 (of 3 total)