Title: Simplify query_posts
Last modified: August 20, 2016

---

# Simplify query_posts

 *  [antware](https://wordpress.org/support/users/antware/)
 * (@antware)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/simplify-query_posts/)
 * If anyone could help me simplify this code on my Template Page I’d be eternally
   grateful:
 * <?php if (is_page(‘eastern-cape’)) {
    query_posts(‘cat=4&showposts=10’); } elseif(
   is_page(‘free-state’)) { query_posts(‘cat=10&showposts=10’); } elseif (is_page(‘
   gauteng’)) { query_posts(‘cat=13&showposts=13’); } elseif (is_page(‘kwazulu-natal’)){
   query_posts(‘cat=14&showposts=14’); } elseif (is_page(‘limpopo’)) { query_posts(‘
   cat=15&showposts=15’); } elseif (is_page(‘mpumalanga’)) { query_posts(‘cat=16&
   showposts=16’); } elseif (is_page(‘north-west’)) { query_posts(‘cat=17&showposts
   =17’); } elseif (is_page(‘northern-cape’)) { query_posts(‘cat=18&showposts=18’);}
   elseif (is_page(‘western-cape’)) { query_posts(‘cat=19&showposts=19’); }
 * ?>
 * I was hoping to maybe just use:
 * <?php if (is_page(‘where this would get the current page slug’)) {
    query_posts(‘
   cat=and this-would-get-the-current-page-ID&showposts=10’); }
 * Please any help would be great. Although I could live with the 9 queries above(
   which are provinces of South Africa, but on another page I have to have all the
   cities/towns which would be hundreds……

Viewing 1 replies (of 1 total)

 *  Thread Starter [antware](https://wordpress.org/support/users/antware/)
 * (@antware)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/simplify-query_posts/#post-2928405)
 * Sorry the &showposts above should all be &showposts=10 *blush*

Viewing 1 replies (of 1 total)

The topic ‘Simplify query_posts’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [antware](https://wordpress.org/support/users/antware/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/simplify-query_posts/#post-2928405)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
