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!
Sounds almost like this:
Thanks! your suggested code:
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…
…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!
- The topic ‘Variable Conditional Tags?’ is closed to new replies.