Reputation: 37
I have a news page where it display all the news and there is a read more button with a permalink function. When it is clicked it will redirect the user into single page news for more information although I can't query the custom fields.
post type: news meta: news
Thank you in advance!
anyway here is my code
$post_id = get_the_ID();
$queried_post = get_post($post_id);
$test = get_custom_field('picture-description', TRUE);
$title = $queried_post->post_title;
echo $title;
echo '<br/>';
echo $test;
echo $queried_post->post_content;
Upvotes: 1
Views: 1186
Reputation: 892
Here are some things you can try:
Make sure your stuff is in a post loop
http://codex.wordpress.org/The_Loop
<?php
if ( have_posts() ) {
while ( have_posts() ) {
$test = get_custom_field('picture-description', TRUE);
the_title();
echo '<br/>';
the_content();
} // end while
} // end if
?>
Try an alternative function
http://codex.wordpress.org/Function_Reference/get_post_meta
get_post_meta($post_id, 'picture-description', TRUE);
Ensure you are in the right file.
For a post single the naming convention of the file should be something like single.php or single-posttype.php
Let me know if any of these things work.
Upvotes: 2