Title: Global wp_query
Last modified: August 19, 2016

---

# Global wp_query

 *  Resolved [Sean Turtle](https://wordpress.org/support/users/turts/)
 * (@turts)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/global-wp_query/)
 * Hi there
 * I’m trying to get a custom css file “injected” into the header of the latest 
   post (of a certain category) via custom fields, which serves as the landing page
   for a new site I’m working on locally.
 * I’ve used this code:
 *     ```
       <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/<?php
       global $wp_query;
       $postid = $wp_query->post->ID;
       echo get_post_meta($postid, 'custom_css', true);
       ?>"
       ```
   
 * But it only loads the custom field for very latest post, regardless of the post
   ID. I’m an intermediate level wordpress user, so please bear with me if it’s 
   obvious what I’m doing wrong.
 * Appreciate it if anyone can offer some help.
 * Thanks

The topic ‘Global wp_query’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [global](https://wordpress.org/support/topic-tag/global/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 0 replies
 * 1 participant
 * Last reply from: [Sean Turtle](https://wordpress.org/support/users/turts/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/global-wp_query/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
