Forums

[resolved] get_post_meta in function.php (3 posts)

  1. teknoledge
    Member
    Posted 1 year ago #

    I have a function that pulls latest 10 entries from specific category and it works fine.

    The problem is I have couple of custom fields for posts in that category that I'd like to be displayed as well but get_post_meta doesnt return anything?

    Looks like this:

    <?php
    function get_phone_offers($cat, $showposts) {
    ?>
    <?php query_posts("cat=$cat&showposts=$showposts");?>
    <?php if (have_posts()) : ?>
    <div class="table">
    	<?php while (have_posts()) : the_post();
    //	$thePostID = $post->ID;
    $thePostID = $post_id;
    .
    .
    .
    	echo get_post_meta($thePostID, "Offer End", $single = true);
    .
    .
    .
    <?php endwhile; ?>
    <?php endif; ?>
    <?php } ?>
  2. Otto42
    Moderator
    Posted 1 year ago #

    Try $thePostID = get_the_ID(); instead.

  3. teknoledge
    Member
    Posted 1 year ago #

    I used get_post_custom($post_id) instead and it works

Topic Closed

This topic has been closed to new replies.

About this Topic