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.
- The topic ‘Global wp_query’ is closed to new replies.