Title: Variable Conditional Tags?
Last modified: August 19, 2016

---

# Variable Conditional Tags?

 *  Resolved [CowboyFrank](https://wordpress.org/support/users/cowboyfrank/)
 * (@cowboyfrank)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/variable-conditional-tags/)
 * Here’s a challenge:
    I would like to make a page template that contains conditional
   tags which draw their data from a custom field. For example:
    - I have five different user groups – 1, 2, 3, 4 and 5.
    - Each user group has a distinct “Information” page.
    - Each Information page uses the Loop to display four different kinds of information–
      news, events, people, and places – specific to each group.
    - Each kind of information has their own post category.
    - Each User Group uses a Custom Field called “Group,” and the value is equal
      to their name. (i.e. Group 1’s value is “1”)
 * The template should include some code that looks at the Page and says, “On the
   Information Page for Group 1, there is a Custom Field ‘Group’ designation of ‘
   1’. So, where the conditional tag calls for News posts, I’ll display any News
   post which also has the Custom Field Group designation of ‘1’.” This way, I can
   use only one template, rather than having to make a separate template (and/or
   separate News, Events, etc. category) for each User Group. Plus, it makes it 
   way easier to add (or subtract) additional user groups.
 * Does this make sense, or am I making it more difficult than I need to? Please
   help!

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/variable-conditional-tags/#post-1263452)
 * Sounds almost like this:
    [http://wordpress.org/support/topic/327148](http://wordpress.org/support/topic/327148)
 *  Thread Starter [CowboyFrank](https://wordpress.org/support/users/cowboyfrank/)
 * (@cowboyfrank)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/variable-conditional-tags/#post-1263456)
 * Michael,
    Thanks! your suggested code: `query_posts('meta_key=city&meta_value
   ='.$value_from_get_post_meta);` has me on the right track, using the following
   code for my own specific purposes: `<?php query_posts('category_name=region-leadership&
   meta_key=Region&meta_value='.$value_from_get_post_meta); ?>` However, the last
   part… `.$value_from_get_post_meta` …doesn’t seem to be calling on the meta_value
   of the page it is creating. Rather, it returns all the posts that fit the first
   two requirements (category and meta_key). The page being created <i>does</i> 
   have a custom field meta_key of Region with a corresponding meta_value. What 
   code should I use to call that value? Thanks again for all your help!
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/variable-conditional-tags/#post-1263484)
 * Use [get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta)
   to get that from your [page](http://codex.wordpress.org/Page).
 * Related
    [Custom Fields](http://codex.wordpress.org/Custom_Fields)
 *  Thread Starter [CowboyFrank](https://wordpress.org/support/users/cowboyfrank/)
 * (@cowboyfrank)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/variable-conditional-tags/#post-1263494)
 * **Thank you** so much for your guidance! With a little learning and experimentation,
   I got it working perfectly!

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

The topic ‘Variable Conditional Tags?’ is closed to new replies.

## Tags

 * [conditional tags](https://wordpress.org/support/topic-tag/conditional-tags/)
 * [template](https://wordpress.org/support/topic-tag/template/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 4 replies
 * 2 participants
 * Last reply from: [CowboyFrank](https://wordpress.org/support/users/cowboyfrank/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/variable-conditional-tags/#post-1263494)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
