Advertisement
naomivd

ACF Custom Loop with Filter

Jun 10th, 2015
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Recepten Index
  4. */
  5. get_header(); ?>
  6.  
  7. <section id="primary" class="content-area full-width" itemtype="http://schema.org/Blog" itemscope="itemscope" itemprop="mainContentOfPage" role="main">
  8.  
  9. <header class="entry-header">
  10. <h2 class="entry-title" itemprop="headline"><?php the_title(); ?></h2>
  11. </header><!-- .entry-header -->
  12.  
  13. <?php
  14. $args = array(
  15. 'post_status' => get_field( 'post_status' ),
  16. 'category__in' => get_field( 'categories' ),
  17. 'tag__in' => get_field( 'tags' ),
  18. 'post_type' => get_field( 'post_type' ),
  19. 'posts_per_page' => get_field( 'posts_per_page' ),
  20. 'orderby' => get_field( 'orderby' ),
  21. 'order' => get_field( 'order' ),
  22. 'nopaging' => true
  23. );
  24. $args['category__in'] = get_field( 'categories' );
  25. $args['tag__in'] = get_field( 'tags' );
  26.  
  27. $postlist = new WP_Query( $args );
  28. if ( $postlist->have_posts() ) : ?>
  29.  
  30. <ul id="filters" class="filter-menu">
  31. <?php while ( $postlist->have_posts() ) : $postlist->the_post(); ?>
  32. <?php $posttags = get_the_tags();
  33. echo '<li><a href="#" class="active" data-filter="*">Alles</a></li>';
  34. if ($posttags) {
  35. foreach($posttags as $tag) {
  36. echo '<li><a href="#" data-filter="' . '.' . $tag->name . '">' . $tag->name . '</a></li>';
  37. }
  38. }
  39. ?>
  40. <?php endwhile; ?>
  41. </ul>
  42.  
  43. <div id="recepten-index" class="row">
  44. <?php while ( $postlist->have_posts() ) : $postlist->the_post(); ?>
  45. <?php $posttags = get_the_tags(); if ($posttags) : $links = array(); foreach($posttags as $tag) {$links[] = $tag->name; } $links = str_replace(' ', '-', $links); $tax = join( " ", $links ); else : $tax = ''; endif; ?>
  46.  
  47. <article id="post-<?php the_ID(); ?>" class="recept-item col-md-4 <?php echo strtolower($tax); ?>" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost"> <?php if( has_post_thumbnail() ) { ?>
  48. <figure class="entry-image">
  49. <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'ikbenirisniet' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_post_thumbnail('featured_image'); ?>
  50. </a>
  51. </figure>
  52. <?php } else { ?>
  53. <figure class="entry-image">
  54. <a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/default.jpg" title="<?php the_title(); ?>"/></a>
  55. </figure>
  56. <?php } ?>
  57. <div class="inner-content">
  58. <header class="entry-header">
  59. <h2 class="entry-title" itemprop="headline">
  60. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'ikbenirisniet' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  61. </header><!-- .entry-header -->
  62. </div>
  63. <div class="clear"></div>
  64. </article><!-- #post-<?php the_ID(); ?> -->
  65. <?php endwhile; else: ?>
  66. <div class="error-not-found">Sorry, no content.</div>
  67. <?php endif; ?>
  68. </div><!-- #recepten-index -->
  69.  
  70. </div>
  71. </section><!-- #primary -->
  72. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement