Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $fabricTerms = get_terms( 'fabric-category'); // ..find sub-categories of 'fabric-category'
- foreach($fabricTerms as $fabricTerm){
- ?>
- <div class="fabricCategory">
- <h2 class="fabrics"><?php echo $fabricTerm->name; ?></h2>
- <?php
- global $wpdb;
- // create blank array..
- $fabricPosts = array();
- // find term_id for sub-category..
- $fabric_category_term_id = $wpdb->get_results( "SELECT term_id FROM {$wpdb->terms} WHERE name = '".$fabricTerm->name."' " );
- foreach($fabric_category_term_id as $fc_id){
- // find taxonomy_ids from term_id..
- $fabric_taxonomy_id = $wpdb->get_results( "SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id = ".$fc_id->term_id." " );
- foreach($fabric_taxonomy_id as $ft_id){
- // find object_id from taxonomy_id..
- $fabric_object_id = $wpdb->get_results( "SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = ".$ft_id->term_taxonomy_id." " );
- foreach($fabric_object_id as $fo_id){
- // add object_id to array..
- array_push($fabricPosts, $fo_id->object_id);
- }
- }
- }
- // if less than 5 posts, get number of posts to detirmine number of loops..
- if( count($fabricPosts) < 5 ){
- $loops = count($fabricPosts);
- }
- else {
- $loops = 5;
- }
- // loop through posts..
- for($v=0; $v<$loops; $v++){
- // get the 1st element from the array..
- $fabricPost = array_shift($fabricPosts);
- // get post data..
- $post = get_post($fabricPost);
- ?>
- <div class="archive">
- <div class="thumbnail"><a href="<?php the_permalink() ?>" title="View <?php $name = get_post_meta($post->ID, 'Fabric Name', true); echo $name; ?> - <?php the_title_attribute(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a></div>
- <h3 class="archiveName" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" title="View <?php $name = get_post_meta($post->ID, 'Fabric Name', true); echo $name; ?> - <?php the_title_attribute(); ?>"><?php $name = get_post_meta($post->ID, 'Fabric Name', true); echo $name; ?></a></h3>
- <ul class="archiveColor"><?php
- $colors = get_the_terms($post->ID, 'color');
- foreach($colors as $color){
- echo "<li><a href='";
- echo bloginfo('url');
- echo "/color/".$color->name."'>";
- echo $color->name."</a></li>";
- } // end foreach
- ?></ul>
- <p class="archiveNumber"><?php the_title(); ?></p>
- </div>
- <?php
- }
- ?>
- <p class="moreArrow"><a href="<?php bloginfo('url'); ?>/fabric-category/<?php echo $fabricTerm->slug; ?>" title="more fabrics in the <?php echo $fabricTerm->name; ?> category"> </a></p>
- </div>
- <?php
- } // end foreach
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement