<?php
/**
* Main loop for displaying ads
*
* @package ClassiPress
* @author AppThemes
*
*/
?>
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div class="post-block">
<div class="post-left">
<?php if(get_option('cp_ad_images') == 'yes') cp_ad_loop_thumbnail(); ?>
</div>
<div class="<?php if(get_option('cp_ad_images') == 'yes') echo 'post-right'; else echo 'post-right-no-img'; ?> <?php echo get_option('cp_ad_right_class'); ?>">
<h3><a href="<?php the_permalink(); ?>"><?php if (mb_strlen(get_the_title()) >= 75) echo mb_substr(get_the_title(), 0, 75).'...'; else the_title(); ?></a></h3>
<div class="price-wrap">
<span class="tag-head"> </span><p class="post-price"><?php if(get_post_meta($post->ID, 'price', true)) cp_get_price_legacy($post->ID); else cp_get_price($post->ID); ?></p>
</div>
<div class="clr"></div>
// my mod refers to a function I put into the theme-functions.php which I call cp_parentcategory
<p class="post-meta"><?php if(cp_parentcategory()) {
global $app_abbr, $post;
// get the current ad category
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
// get the current ad category parent id
$parent = $term->parent;
// WP doesn't have a function to grab the top-level term id so we need to
// climb up the tree and create a list of all the ad cat parents
while ($parent):
$parents[] = $parent;
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
$parent = $new_parent->parent;
endwhile;
}?>
<span class="folder"><?php if (get_the_category()) the_category(', '); else echo get_the_term_list($post->ID, 'ad_cat', '', ', ', ''); ?></span> | <span class="owner"><?php if (get_option('cp_ad_gravatar_thumb') == 'yes') appthemes_get_profile_pic(get_the_author_meta('ID'), get_the_author_meta('user_email'), 16) ?><?php the_author_posts_link(); ?></span> | <span class="clock"><span><?php echo appthemes_date_posted($post->post_date); ?></span></span></p>
// the rest of the loop-ad.php page continues & I trust you know where to put the code above
// my shortened breadcrumb for categories
function cp_parentcategory() {
global $app_abbr, $post;
$delimiter = '';
$currentBefore = '<span class="current">';
$currentAfter = '</span>';
if ( !is_home() || !is_front_page() || is_paged() ) :
$flag = 1;
echo '<div id="crumbs">';
echo '<a href="' . get_bloginfo('url') . '">' . __('', '') . '</a> ' . $delimiter . ' ';
// figure out what to display
switch ($flag) :
case is_tax('ad_tag'):
echo $currentBefore . __('Ads tagged with', 'appthemes') .'' . single_tag_title('', false) . '' . $currentAfter;
break;
case is_tax():
// get the current ad category
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
// get the current ad category parent id
$parent = $term->parent;
// WP doesn't have a function to grab the top-level term id so we need to
// climb up the tree and create a list of all the ad cat parents
while ($parent):
$parents[] = $parent;
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
$parent = $new_parent->parent;
endwhile;
// if parents are found display them
if(!empty($parents)):
// flip the array over so we can print out descending
$parents = array_reverse($parents);
// for each parent, create a breadcrumb item
foreach ($parents as $parent):
$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
$url = get_term_link( $item->slug, 'ad_cat' );
echo '<a href="'.$url.'">'.$item->name.'</a> ' . $delimiter . ' ';
endforeach;
endif;
//echo $currentBefore . $term->name . $currentAfter;
break;
endswitch;
echo '</div>';
endif;
}
There are currently 1 users browsing this thread. (0 members and 1 guests)