Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Outputs a custom loop
- */
- add_action( 'genesis_loop', 'genesis_kris_loop2' );
- wp_reset_query();
- function genesis_kris_loop2() {
- $cat_order = get_field('category_order');
- // get all the categories from the database
- $cats = get_categories( array (
- 'meta_key' => 'category_order',
- 'orderby' => $cat_order, //or 'meta_value_num'
- 'count',
- 'posts_per_page' => -1,
- 'exclude' => '1, 7, 6, 8, 9, 10',
- 'order' => 'ASC',
- ) );
- // loop through the categries
- foreach ($cats as $cat) {
- // setup the cateogory ID
- $cat_id= $cat->term_id;
- // Make a header for the cateogry
- echo '<h2 class=slider-heading>'.$cat->name.'</h2>';
- echo '<div class="owl-demo">';
- // create a custom wordpress query
- query_posts("cat=$cat_id&post_type=case-study&post_per_page=-1&order=ASC"); //-1 shows all posts per category.
- // start the wordpress loop!
- if (have_posts()) : while (have_posts()) : the_post();
- echo '<div class="item2"><a href="' . get_permalink() . '">';
- if ( has_post_thumbnail() ) {
- the_post_thumbnail('slide-thumb');
- }
- echo '<h3 class="bloghead2">';
- the_title();
- echo '</h3>';
- echo '</a></div>';
- endwhile;
- endif; // done our wordpress loop. Will start again for each category ?>
- </div>
- <?php }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement