[resolved] Global wp_query (1 post)

  1. Sean Turtle
    Posted 5 years ago #

    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.


Topic Closed

This topic has been closed to new replies.

About this Topic