• Resolved danbranigan

    (@danbranigan)


    Hi there,

    I’m trying to pull a custom field from my posts from within the loop on my category.php template. I’m using $post->ID to retrieve the post ID within my get_post_meta() function – but it’s not working.

    I’ve tested it by actually setting a value for the post ID, e.g. 1 and it works fine then. Strange I haven’t had this problem pulling in meta data on posts or pages?

    I’ve also tried setting a variable, e.g.

    $link_ID = $post->ID, and then using this new variable in the get_post_meta() function. But gain , no joy. Weird ;cos when I echo the value of the $link_ID variable it does seem to be picking up the correct value!!

    Any help appreciated.

    regards

    Dan

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter danbranigan

    (@danbranigan)

    Sorry, here’s my code:

    <?php $external_link = get_post_meta($post->ID, 'external-link', true); ?>
    <a class="external-link" href="<?php echo $external_link; ?>" target="_blank">Buy now from Nauticalia &raquo;</a>
    Thread Starter danbranigan

    (@danbranigan)

    Sorry I fixed it I was being a complete muppet!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pulling in custom field within loop on category page’ is closed to new replies.