Title: Custom Fields Query
Last modified: August 30, 2016

---

# Custom Fields Query

 *  [rockyintown](https://wordpress.org/support/users/rockyintown/)
 * (@rockyintown)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/custom-fields-query-1/)
 * Im trying to pull a custom field from a page to a template and run into a little
   difficulty
 * I am currently using the below query to query my tag ‘autoshows’, and would like
   to change the query to use the custom tag field used on my page
 *  ‘<?php // this is where the upper sub blog gets printed
    query_posts(‘showposts
   =4&tag=autoshows&orderby=title&order=ASC’); ?>’
 * I have made a Custom Field called TTAG
    and are trying to get the query to show
   posts where CustomField.TTAG = my CustomField.Value
 * all help would be appreciated… cheers

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

 *  [John Parris](https://wordpress.org/support/users/mindctrl/)
 * (@mindctrl)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/custom-fields-query-1/#post-6403753)
 * Hi there,
 * Check the [codex page for query_posts](https://codex.wordpress.org/Function_Reference/query_posts)
   and note that it says this function should not be used, for the reasons listed
   there.
 * With that in mind, there’s another, better way to get the posts that are tagged
   with your custom field using [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query).
 * See this example for getting posts with the ttag value of autoshows: [https://gist.github.com/anonymous/5420c2bfd96fea7184b5](https://gist.github.com/anonymous/5420c2bfd96fea7184b5)
 *  Thread Starter [rockyintown](https://wordpress.org/support/users/rockyintown/)
 * (@rockyintown)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/custom-fields-query-1/#post-6403765)
 * thanks for your help Much appreciated.. i will see if I can get that to do what
   I want..

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

The topic ‘Custom Fields Query’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [rockyintown](https://wordpress.org/support/users/rockyintown/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/custom-fields-query-1/#post-6403765)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
