Calling a custom category (2 posts)

  1. crispmedia
    Posted 3 years ago #

    I am creating a custom template called "city index". The file needs to include an index for a specific category (among other things). Right now, I've figured out how to hard-code the category into the template file:

    if(have_posts()) :?>

    Where 61 is the category I would like to use.

    I would like to replace 61 with a custom field, specified for the page.

    So something that lets me use something like:
    <?php echo get_post_meta($post->ID, ‘category', true); ?>

    where I specify "61" in a custom field associated with the page.

    I'm a complete PHP newbie, so what do I need to do to insert the above where "61" is? Will that work? Is there a better method? Any feedback offered is appreciated.

  2. Mohd Rafie
    Posted 3 years ago #

    Hi there,

    When you call the get_post_meta it should be inside the loop ie the query_posts

    The codex doco has an example for calling a custom field value

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.