Display taxonomies using custom page template?
-
Hi!
I got this code off of WP, and it’s awesome.<?php /** * Template Name: Page for the tutorials * * Selectable from a dropdown menu on the edit page screen. */ ?> <?php get_header(); ?> <div id="container"> <div id="content"> <?php $type = 'tutorial'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 10, 'caller_get_posts'=> 1 ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); ?> <?php get_template_part( 'loop', 'index' );?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
However, I do not know on how to display the taxonomies there, for my custom post type. I got it to work before by using this type of code, and that worked awesome as well, except for the fact that the metadata (posted in, by author etc.) wasn’t displayed.
<?php /* Template Name: Tutorials */ ?> <?php get_header(); ?> <div id="container"> <div id="content"> <?php $tutorial = new WP_Query( array( 'post_type' => 'tutorial', 'posts_per_page' => 10, 'orderby' => 'rand' ) ); while ( $tutorial->have_posts() ) : $tutorial->the_post(); the_title( '<h2><a href="' . get_permalink() . '" >', '</a></h2>' ); ?> <div class="entry-content"> <?php the_content(); ?> <?php echo get_the_term_list( $post->ID, 'language', '<p>Language: ', ', ', '</p>' ); ?> </div> <?php endwhile; ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
Also I’d like to know how to get the CPT’s displayed within the loop. Justin Tadlock’s recipe for that isn’t working anymore…
add_filter('pre_get_posts','my_get_posts'); function my_get_posts($query ){ if ( is_home()) $query->set('post_type', array('post', 'page', 'album', 'movie', 'quote', 'attachment')); return $query;
Thanks a lot!
[sig moderated]
- The topic ‘Display taxonomies using custom page template?’ is closed to new replies.