Hi Jakus,
Can you post your repeater template?
Thread Starter
jakus
(@jakus)
<div class="col-md-4 ajax-item"<?php if (! has_post_thumbnail() ) { echo ' class="no-img"'; } ?>>
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('large'); ?>
</a>
<?php } ?>
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php $term_list = wp_get_post_terms($post->ID, 'portfolio-category', array("fields" => "all")); ?>
<p><a href="<?= esc_url(home_url('/')); ?>our-events/<?php echo $term_list[0]->slug ; ?>"><?php echo $term_list[0]->name ; ?></a></p>
<?php the_excerpt(); ?>
</div>
Try this:
<div class="col-md-4 ajax-item"<?php if (! has_post_thumbnail() ) { echo ' class="no-img"'; } ?>>
<?php global $post; ?>
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('large'); ?>
</a>
<?php } ?>
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<?php $term_list = wp_get_post_terms($post->ID, 'portfolio-category', array("fields" => "all")); ?>
<p><a href="<?= esc_url(home_url('/')); ?>our-events/<?php echo $term_list[0]->slug ; ?>"><?php echo $term_list[0]->name ; ?></a></p>
<?php the_excerpt(); ?>
</div>
Thread Starter
jakus
(@jakus)
D’oh! Why didn’t I think of that.. Sweet, worked like a charm. Thanks man.
Thread Starter
jakus
(@jakus)
One other question, slightly unrelated..
If I want to create a shortcode to use on a Taxonomy template page and only show posts assigned to the custom Taxonomy being viewed, how would I filter this with the shortcode?
Hope this makes sense.
Thanks!
Thread Starter
jakus
(@jakus)
Got it! .. Is this an OK way of doing it?
<?php
$terms = wp_get_object_terms( $post->ID, 'portfolio-category' );
if ( ! empty( $terms ) ) {
if ( ! is_wp_error( $terms ) ) {
foreach( $terms as $term ) {
$taxterm = $term->slug;
}
}
}
?>
<div class="row">
<?php
echo do_shortcode('[ajax_load_more post_type="portfolio" taxonomy="portfolio-category" taxonomy_terms="'.$taxterm.'"]');
?>
</div>
Is this for a Taxonomy Term archive page?
If so, you could simplify by using this.
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
?>
<div class="row">
<?php
echo do_shortcode('[ajax_load_more post_type="portfolio" taxonomy="portfolio-category" taxonomy_terms="'.$term->slug.'"]');
?>
</div>
Thread Starter
jakus
(@jakus)
Thanks very much for the simplification, perfect!