I have created one custom field in WordPress’ edit post section, and am able to save the value by following this posts: WordPress – Adding custom field to the post screen.
I’m able to retrieve the posts of the specific category, but I’m unable to retrieve the value of custom field.
As seen in image above, there is a custom post field at highlighted at the top left. The other highlighted field is to show that the post belongs to the “Portfolio” category.
Here is the code I used to retrieve the posts of the category “Portfolio”
<?php
$the_query = new WP_Query(array(
'category_name' => 'Portfolio',
'posts_per_page' => 9,
'order' => 'DESC'
));
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<p>The title: <?php the_title(); ?></p>
<p> custome value: <?php get_post_meta( $post_ID, '_ssb_portfolio_url', true); ?> </p>
<p>The Content: <?php the_content(); ?></p>
<?php
endwhile;
wp_reset_postdata();
?>
I’m able to get the value of the title of the post and the content of the post, but not custom field value. What wrong in my code?
You can use get_post_custom( $post_id )
In your case
Then
$custom
is an array of your custom fields