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.

http://www.vooshthemes.com/blog/wordpress-tip/create-a-professional-portfolio-using-wordpress-3-0-custom-post-types/

I'm using the above tutorial to build custom portfolio pages. The custom portfolio pages are working... but I can't figure out how to display the Website URL I enter in my custom post meta field (website_url).

Shouldn't <?php echo $website_url; ?> work?

How do I call specific post meta? The normal call for all post_meta is <?php the_meta(); ?>, but what if I just want to call a specific piece of it (website_url in this example)?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

you can use <?=$website_url?> in the portfolio template like

<strong>URL: </strong><a href="<?=$website_url?>"><?=$website_url?></a>

to make it like follow

<?php
/*
Template Name: Portfolio
*/
?>
<?php get_header(); ?>
    <div id="content">
    <?php 
        $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 10)); 
    ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <?php   
        $custom = get_post_custom($post->ID);
        $screenshot_url = $custom["screenshot_url"][0];
        $website_url = $custom["website_url"][0];
    ?>
        <div id="portfolio-item">
        <h1><?php the_title(); ?></h1>
        <a href="<?=$website_url?>"><?php the_post_thumbnail(); ?> </a>
        <strong>URL: </strong><a href="<?=$website_url?>"><?=$website_url?></a>
        <?php the_content(); ?>
    </div>
        <?php endwhile; ?>  
        </div><!-- #content -->
<?php get_footer(); ?>

You can change the placement to match your standers

share|improve this answer
    
did you find it use full if so please mark it as a correct answer. –  phantom.omaga Nov 5 '11 at 6:58
add comment

Assuming you are inside the loop:

$website_url = get_post_meta( $post->ID, 'website_url', true );

Where $post->ID is the id of the current post. Either accessed by the $post global or the_ID() / get_the_ID() or some other method.

share|improve this answer
add comment

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.