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.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | // 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'); |