Basic get_post_meta call outside loop?
-
I’ve tried several code snippets and they either don’t work for me or I’m not using them correctly-
Situation is this, I’ve set up a small block for a sidebar that recalls custom fields from a specified post ID. Within the loop it works flawlessly. A sample of that from my sidebar.php is here:<?php $featuredOne = 342; $featuredTwo = 155; ?> <ul><li><a href="<?php echo get_permalink($featuredOne) ?>"><?php echo get_post_meta($featuredOne, short_name, true) ?></a>That’s just a piece but you get the idea. What I want to do now is make a new php file that run that snippet and spits out the html so I can @readfile that php on another website.
I’m assuming I need to use some variation of $wp_query to get the meta out of the loop but I don’t know what code to use and I don’t know where this new php file will need to live in my directory structure relative to my wordpress install.Hopefully this makes sense,
Thanks-
The topic ‘Basic get_post_meta call outside loop?’ is closed to new replies.