maxworkingwell

items with children

Aug 27th, 2022
1,276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. add_shortcode('items_with_children', 'items_with_children_func');
  2. function items_no_child_func(){
  3.  
  4. $args = array(
  5.     'post_type' => array('subtitle-project'),
  6.     'post_status' => array( 'publish' ),
  7.     'posts_per_page'  => -1,
  8.     'fields'    => 'ids'
  9.  );
  10. $posts = get_posts( $args );
  11. $drama = array();
  12. foreach ($posts as $item){
  13. $drama[] = toolset_get_related_post( $item, 'related-drama', 'parent' );
  14. }
  15. if(!empty($drama)) {
  16. return implode(', ', $drama);
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment