Title: Retrieve post_type querystring value?
Last modified: August 20, 2016

---

# Retrieve post_type querystring value?

 *  Resolved [fredhead](https://wordpress.org/support/users/fredhead/)
 * (@fredhead)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/retrieve-post_type-querystring-value/)
 * I need to retrieve the post_type querystring value so that I can display the 
   appropriate page heading on my archive page based on content type. I’ve confirmed
   the querystring values exist using this code from the forum:
 *     ```
       <?php
       echo "<pre>"; print_r($wp_query->query_vars); echo "</pre>";
       ?>
       ```
   
 * [http://wordpress.org/support/topic/how-to-get-query-string](http://wordpress.org/support/topic/how-to-get-query-string)
 * However, when I use $_GET to grab the querystring value like this:
 * `$post_type = $_GET[post_type];`
 * I get no value. What is the secret to capturing WordPress querystring values 
   for this kind of task?
 * Thanks!

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/retrieve-post_type-querystring-value/#post-2227975)
 * Get the post_type from the $post object.
 *  Thread Starter [fredhead](https://wordpress.org/support/users/fredhead/)
 * (@fredhead)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/retrieve-post_type-querystring-value/#post-2228242)
 * To clarify Esmi’s suggestion, this works:
 * `$page_type = $post->post_type;`
 * But this also appears to work:
 * `$page_type = get_query_var('post_type');`
 * I found a list of $post values here:
 * [http://www.rlmseo.com/blog/wordpress-post-variable-quick-reference/](http://www.rlmseo.com/blog/wordpress-post-variable-quick-reference/)
 * Thanks, Esmi, for at least the direction …

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

The topic ‘Retrieve post_type querystring value?’ is closed to new replies.

## Tags

 * [Query String](https://wordpress.org/support/topic-tag/query-string/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [fredhead](https://wordpress.org/support/users/fredhead/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/retrieve-post_type-querystring-value/#post-2228242)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
