• Resolved dgissen

    (@dgissen)


    I’ve been taking a wordpress lynda.com course by Morten Rand-Hendriksen (who may be on these forums?) and in a chapter on developing custom templates for a mock food blog, where the student develops a custom post template that lists taxonomies, he suddenly goes from showing how to list custom taxonomies in twentytwelve to showing how its done in twentyeleven. The problem is that he never returns the student to the original twentytwelve theme – showing how this would be done in twentytwelve. So, my question is where would this code (used in his course and shown beloe) go in twentytwelve? and if it wouldn’t work in twentytwelve, what code will list custom taxonomies in the beginning of a custom post?

    <div class="entry-meta-custom">
    			<div>Meal type: <?php echo get_the_term_list( $post->ID, 'meal-type', '', ', ', '' ); ?></div>
    			<div>Servings: <?php echo get_the_term_list( $post->ID, 'servings', '', ', ', '' ); ?></div>
    			<div>Difficulty: <?php echo get_the_term_list( $post->ID, 'difficulty', '', ', ', '' ); ?></div>
    			<div>Ingredients: <?php echo get_the_term_list( $post->ID, 'ingredients', '', ', ', '' ); ?></div>
    		</div><!-- .entry-meta-custom -->

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter dgissen

    (@dgissen)

    Ok, I’m mostly there. The below is in a file I named single-producers.php.
    Now I just need to figure out how to get the custom taxonomy data to appear below the page title. Right now it appears above it. Does anyone have an easy fix?

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    			<?php get_template_part( 'content', get_post_type() ); ?>
    
    			<div class="entry-meta-custom">
    			<div>Country: <?php echo get_the_term_list( $post->ID, 'country', '', ', ', '' ); ?></div>
    			<div>Region: <?php echo get_the_term_list( $post->ID, 'region', '', ', ', '' ); ?></div>
    			<div>Appellation: <?php echo get_the_term_list( $post->ID, 'appellation', '', ', ', '' ); ?></div>
    		</div><!-- .entry-meta-custom -->
    
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php comments_template( '', true ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Thread Starter dgissen

    (@dgissen)

    Ok; I think I figured it out. vis-a-vis the above:

    I made a file content-producers where I included this data:

    <?php
    /**
     * The template used for displaying page content in page.php
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    ?>
    
    	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<header class="entry-header">
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    		</header>
    
    <div class="entry-meta-custom">
    			<div>Country: <?php echo get_the_term_list( $post->ID, 'country', '', ', ', '' ); ?></div>
    			<div>Region: <?php echo get_the_term_list( $post->ID, 'region', '', ', ', '' ); ?></div>
    			<div>Appellation: <?php echo get_the_term_list( $post->ID, 'appellation', '', ', ', '' ); ?></div>
    		</div><!-- .entry-meta-custom -->
    
    		<div class="entry-content">
    			<?php the_content(); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    		<footer class="entry-meta">
    			<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    		</footer><!-- .entry-meta -->
    	</article><!-- #post -->

    Then I hooked it into the original single-producers.php file but with the following changes – specifically calling for “content-producers” instead of :content”.

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    			<?php get_template_part( 'content-producers', get_post_type() ); ?>
    
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php comments_template( '', true ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    It appears to work, but will I get into trouble down the road?

    Yes, what you have done will work and is correct. There are as many different ways of incorporating this type of function as there are developers out there. The course in question was created to teach general concepts around how to incorporate custom post types in a WordPress theme and you have done just that – taken a general concept and made it work within your theme.

    The original course was created using Twenty Ten as the base and we made an update to cover inclusion in Twenty Eleven. The different tools and snippets delivered in the course are written to work with any theme, not just these two, and as you were able to do yourself they are meant to be incorporated the way you want them to be, not just the way I did them in the course.

    Your solution works and you should not run into any issues down the road.

    Thread Starter dgissen

    (@dgissen)

    thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Where does get_the_term_list go in twentytwelve’ is closed to new replies.