Advertisement
afsarwebdev

wp if post format

May 6th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. // if post format
  2. <div class="col-md-12">
  3.  
  4. <?php
  5. // the query
  6. $ic_post_format = new WP_Query( array(
  7. 'posts_per_page' => 4,
  8. 'post_type' => 'post',
  9. ));
  10.  
  11. if( $ic_post_format->have_posts() ): while ( $ic_post_format->have_posts() ) : $ic_post_format->the_post();
  12. // get_template_part( 'template-parts/feature_content', 'post', get_post_format() );
  13.  
  14. $format = get_post_format() ? : 'standard';
  15. if ( $format == 'aside' ) : ?>
  16.  
  17. <?php get_template_part( 'template-parts/feature_content', 'post', get_post_format() ); ?>
  18.  
  19. <?php else: ?>
  20.  
  21. <div class="ic-card">
  22. <div class="media">
  23. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('hpost'); ?></a>
  24. <div class="media-body">
  25. <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h3>
  26. <span class="ic-cat"><a href="<?php the_permalink(); ?>"><?php the_category(' , ') ?> </a> / <?php echo date('j F Y'); ?></span>
  27. <?php the_excerpt(); ?>
  28. </div>
  29. </div>
  30. </div>
  31.  
  32. <?php endif;
  33.  
  34. endwhile;
  35. else :
  36. echo wpautop( 'Sorry, no posts were found' );
  37. endif;
  38. wp_reset_query();
  39. ?>
  40. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement