I'm having trouble getting a Post ID on the homepage. I have my wordpress configured to only show a single post on the home page, and I need the ID of that post to fetch the custom stylesheet for that particular post. The code works fine on a single page, but on the homepage I'm not sure whats going on...
So how can I grab post meta data on the homepage from the latest post (in a certain category)??
<?php
$id = $wp_query->post->ID;
$css_docs = get_post_meta($id, 'custom_css', false);
$js_docs = get_post_meta($id, 'custom_javascript', false);
if (!empty($css_docs))
{
echo '<!--Home Page Custom css for '.get_the_title().'.-->'."\n";
foreach ($css_docs as $css)
{
echo '<link rel="stylesheet" href="'.$css.'" type="text/css" media="screen" />'."\n";
}
}
if (!empty($js_docs))
{
echo '<!--Custom javascript for '.get_the_title().'.-->'."\n";
foreach ($js_docs as $js)
{
echo '<script src="'.$js.'" type="text/javascript"></script>'."\n";
}
}
?>