Title: [Plugin: Articles] Changes to custom select query
Last modified: August 19, 2016

---

# [Plugin: Articles] Changes to custom select query

 *  Resolved [bdayne](https://wordpress.org/support/users/bdayne/)
 * (@bdayne)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/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](http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query).
   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?

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

 *  Thread Starter [bdayne](https://wordpress.org/support/users/bdayne/)
 * (@bdayne)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-articles-changes-to-custom-select-query/#post-839083)
 * Bump.
 * Anyone? Bueller? Anyone?
 *  Thread Starter [bdayne](https://wordpress.org/support/users/bdayne/)
 * (@bdayne)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-articles-changes-to-custom-select-query/#post-839171)
 * Articles plugin didn’t quite suit my needs, but I found a nice little plugin 
   that didn’t exist a few days ago, and thought I should pass it along. It totally
   solved my issue of displaying a select list of categories on a nav page. [Archives By Selected Category](http://www.dagondesign.com/articles/archives-by-selected-categories-plugin-for-wordpress/)
   is from the friendly folks at Dagon Design, and is basically a stripped down 
   version of their site map plugin, for those who don’t need a lot of bells and
   whistles.

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

The topic ‘[Plugin: Articles] Changes to custom select query’ is closed to new replies.

 * 2 replies
 * 1 participant
 * Last reply from: [bdayne](https://wordpress.org/support/users/bdayne/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-articles-changes-to-custom-select-query/#post-839171)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
