WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using WordPress 3.5.1 / Twenty Twelve theme. I am using custom fields and displaying them in category.php in the following way, the php is setup inside category.php in the "/* Start the Loop */ "

$metastime = get_post_meta($post->ID,'user_submit_starttime',true);
echo '<a class="metastime">'.$metastime.'</a>';
$metaetime = get_post_meta($post->ID,'user_submit_endtime',true);
echo '<a class="metaetime">'.$metaetime.'</a>';
$metaloc = get_post_meta($post->ID,'user_submit_location',true);
echo '<a class="metaloc">'.$metaloc.'</a>';

It works as the custom fields are displaying when I view the category archives (the custom fields are displayed under each post title), but I assume there is a better function to use. Like the the following?

get_template_part( 'content', get_post_format() );

Since that code is specific to content.php, I would like the custom fields to show up where the

<div class="entry-content"> <?php the_content('Read more...'); ?> </div>

Resides in content.php, What is the best way to display the custom fields so they display were the "entry-content" is displayed in category.php ?

share|improve this question
up vote 0 down vote accepted

You might try the the_content filter with the conditional tag is_category() to append a string to the post content when viewing the category archives :

add_filter( 'the_content', 'custom_the_content' );
function custom_the_content( $content ){
    if( is_category() ):
        $metastime = get_post_meta( get_the_ID(), 'user_submit_starttime', true );
        $metaetime = get_post_meta( get_the_ID(), 'user_submit_endtime'  , true );
        $metaloc   = get_post_meta( get_the_ID(), 'user_submit_location' , true );
        $content  .= '<a class="metastime">' . $metastime . '</a>';
        $content  .= '<a class="metaetime">' . $metaetime . '</a>';
        $content  .= '<a class="metaloc">'   . $metaloc   . '</a>';
    return $content;
share|improve this answer
you can add this into your functions.php file in the current theme directory, or better yet create a plugin from this. – birgire Jun 17 '13 at 19:42
Adding your code into functions.php did the trick, Thank you. – Mills Jun 17 '13 at 19:45

Your Answer


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.