WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this code to call some custom post meta named port_excerpt:

global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'port_excerpt', true);

This works like a dream when used on the template it is intended for: http://themeforward.com/demo2/portfolio/new-one/. But the custom post template I am using (as in 3.0 custom post templates) is being used for a portfolio, as a result I also need to call this on my portfolio page: http://themeforward.com/demo2/portfolio/

How do I call port_excerpt, which is meta contained within a custom post, on the portfolio page above?

share|improve this question
up vote 0 down vote accepted

You need to put this inside the loop running on the portfolio page.

echo get_post_meta( get_the_ID(), 'port_excerpt', true );
share|improve this answer

Inside your post loop, use $post->ID instead of $wp_query->post->ID. If you could post the loop you're using it would be clearer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.