[Plugin: Articles] Changes to custom select query
-
I’m trying to find a way to list posts by title in ascending order, sorted by category, on a single page and, after trying various plugin and php solutions, I’ve settled on Alex King’s Articles plugin. It’s nearly perfect for my needs, but requires what some minor changes. At least I hope they’re minor. 😉 The posts I’d like to display are all in two top level categories, so when these posts are given the custom field key and value, they show up twice on the page, and I want them once, listed only by the second category in question.
I’ve had a look at the Articles plugin and realized that the custom query is similar to the one described in the Codex. In the section on queries based on custom field and category, there’s a line of code that got my attention:
SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) <strong>WHERE $wpdb->term_taxonomy.term_id = 1,2,3</strong> AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->posts.post_status = 'publish' AND $wpdb->postmeta.meta_key = 'paragraf' ORDER BY $wpdb->postmeta.meta_value ASC
If I’m understanding this right, the highlighted code limits the display to only those category numbers listed. I think I’m on the trail of something here, however, this is really pushing the limits of my personal mySQL knowledge. Outside of randomly inserting the line of code into the plugin, and hoping for the best, I’m stuck. I’m also open to solutions outside the plugin as well. Can anyone help?
- The topic ‘[Plugin: Articles] Changes to custom select query’ is closed to new replies.