Advertisement
dimti

Untitled

Aug 16th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2.  
  3. add_shortcode( 'articles_posts', 'articles_posts_shortcode' );
  4.  
  5. function articles_posts_shortcode($atts) {
  6.     $the_query = new WP_Query( [
  7.         'tax_query'           => [
  8.             [
  9.                 'taxonomy' => 'category',
  10.                 'field'    => 'slug',
  11.                 'terms'    => $atts['slug'],
  12.             ],
  13.         ],
  14.         'nopaging'      => true,
  15.     ] );
  16.  
  17.  
  18.     foreach ($the_query->posts as $post) {
  19.         ?>
  20.         <p><?=$post->post_title?></p>
  21.         <p><?=get_the_excerpt($post);?></p>
  22.         <p><?=get_the_post_thumbnail( $post->ID );?></p>
  23.         <?php
  24.     }
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement