WordPress.org

Forums

Custom Post Type, Styling By Custom Taxonomies (1 post)

  1. sosukeinu
    Member
    Posted 3 years ago #

    Hello,
    I have a custom post type called 'Inspirations', that has a hierarchical, custom taxonomy associated with it called 'inspirationtype'. I would like to use this like categories, and have each inspiration type styled differently. Right now, I'm using a page with a custom template to call all posts of the 'inspirations', but I'm having a very difficult time it to call correctly. I am using the code below. Any help will be very very very appreciated. Thank you.

    $loop = new WP_Query( $args );
    
    	while ( $loop->have_posts() ) : $loop->the_post(); ?>
    	<?php $inspiration_type = wp_get_object_terms( $post->ID, 'inspirationtype'); ?>
    	<?php if ( $inspiration_type = 'art' ) : ?>
    		<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    
    		<a href="<?php $atturl = wp_get_attachment_url(get_post_thumbnail_id());
    		echo preg_replace('/-e[0-9]{13}/', '', $atturl); ?>">
    		<div class="post-featured-image"><?php the_post_thumbnail('featured-image');  ?>
    			<?php the_post_thumbnail_caption('featured-image'); ?></div>
    		</a>
    	<?php elseif ( $inspiration_type = 'quote' ) : ?>
    		<?php $quote_author = wp_get_object_terms( $post->ID, 'writer'); ?>
    
    		<div id="frontpage_blockquote" class="drop-shadow lifted">
    			<?php the_content(); ?><br /><em>~ <?php echo $quote_author ?></em>
    		</div>
    	<?php else : ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    				<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    				<div class="post-featured-image"><?php the_post_thumbnail('featured-image');  ?>
    					<?php the_post_thumbnail_caption('featured-image'); ?></div>
    
    	<?php endif; ?>
    <?php	endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic