Guest User

Untitled

a guest
Dec 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. $terms_array = array(
  3. 'taxonomy' => 'post_tag',
  4. );
  5. $services_terms = get_terms($terms_array);
  6. foreach($services_terms as $service): ?>
  7. <h4><?php echo $service->name; ?></h4>
  8. <?php
  9. $post_args = array(
  10. 'post_type' => 'attachment',
  11. 'post_mime_type' => ['application/pdf'],
  12. 'numberposts' => -1,
  13. 'post_status' => null,
  14. 'post_parent' => null,
  15. 'tax_query' => array(
  16. array(
  17. 'taxonomy' => 'post_tag',
  18. 'field' => 'slug',
  19. 'terms' => 'sub', // ['sub', 'ins'] does not work
  20. )
  21. )
  22. );
  23. $myposts = get_posts($post_args); ?>
  24. <ul>
  25. <?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
  26. <li>
  27. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  28. </li>
  29. <?php endforeach; // Term Post foreach ?>
  30. </ul>
  31. <?php wp_reset_postdata(); ?>
  32.  
  33. <?php endforeach; // End Term foreach; ?>
Add Comment
Please, Sign In to add comment