Show content from single.php in category.php
-
I am using WordPress 3.5.1. / Twenty Twelve Theme
I would like to show all the content I have in single.php to show in category.php.
I have it working by using the second code block example, but I assume there is a better function to use.
The following code below displays custom fields inside the <header class=”entry-header”> in single.php (this is the only content displayed in a single post)<?php echo get_post_meta($post->ID, "user_submit_starttime", true); ?> <?php echo get_post_meta($post->ID, "user_submit_endtime", true); ?> <?php echo get_post_meta($post->ID, "user_submit_location", true); ?>
The following code is only what I want to show up in categories.php,
So far I have the following code (same as the above code, but formatted differently) setup inside the 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 but I assume there is a better function to use. Like the the following?
get_template_part( 'content', get_post_format() );
- The topic ‘Show content from single.php in category.php’ is closed to new replies.