Some options to add a grid of taxonomy pages. The first doesn’t include pageing the second requires adding a second post type to hold the pages.
// no pageing with this one
function jma_series_grid ($atts){
ob_start();
extract( shortcode_atts( array(
), $atts ) );
$series_array = get_terms( 'series' );
foreach ($series_array as $series) {//get values from add fields to tax plugin
$series_im_array = get_tax_meta($series->term_id,'image_field_id');
$series_text = get_tax_meta($series->term_id,'wysiwyg_field_id');
$series_date = get_tax_meta($series->term_id,'date_field_ids');
echo '<div class="grid-item col-sm-4 series-grid-item">';
echo '<a href="';
echo get_term_link( $series, 'series' );
echo '">';
echo wp_get_attachment_image( $series_im_array['id'], 'tb_grid');
echo '</a>';
echo '<h3 class="news-title"><a href="';
echo get_term_link( $series, 'series' );
echo '">';
echo $series->name;
echo '</a></h3>';
echo '</div>';
}
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
$x = ob_get_contents();
ob_end_clean();
return $x;
}
add_shortcode('series_grid', 'jma_series_grid');
function jma_new_series_grid ($atts){
ob_start();
extract( shortcode_atts( array(
'post_type' => 'series_page',//default post type
'tax' => false,//a comma seperated list of taxonomies
), $atts ) );
if($tax){
$tax = explode(',', $tax);
$tax_query = array(
array(
'taxonomy' => $post_type,
'field' => 'term_id',
'terms' => $tax,
),
);
}else{
$tax_query =null;
}
$args = array(
'post_type' => $post_type,
'tax_query' => $tax_query[0],
'orderby' => 'name',
'order' => 'ASC',
'posts_per_page' => 2
);
if ( get_query_var('paged') ) {//for pageing
$args['paged'] = get_query_var('paged');
} else if ( get_query_var('page') ) {
$args['paged'] = get_query_var('page');
} else {
$args['paged'] = 1;
}
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<div class="grid-item col-sm-4 series-grid-item">';
echo '<a href="';
echo the_permalink();
echo '">';
echo the_post_thumbnail( 'tb_grid');
echo '</a>';
echo '<h3 class="news-title"><a href="';
echo the_permalink();
echo '">';
echo the_title();
echo '</a></h3>';
echo '</div>';
}
echo '<div class="clear"></div>';
echo themeblvd_pagination( $the_query->max_num_pages );
$x = ob_get_contents();
ob_end_clean();
return $x;
} else {
echo 'sorry no results';// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
}
add_shortcode('new_series_grid', 'jma_new_series_grid');