Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

<?php
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

2 Answers 2

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

 
discard

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.