Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Reply To: Display child posts by parent ID

$
0
0

I have this working now. I don't know what 'meta_key' => 'wpcf-description' is supposed to do but it was causing my query to return zero results.

Here is the code that is functioning as desired. Please let me know if you have any suggestions for improvement:

<?php
  $parent_id = wpcf_pr_post_get_belongs(get_the_ID(), 'course_category');
  $childargs = array(
    'post_type' => 'course',
    'numberposts' => -1,
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'meta_query' => array(array('key' => '_wpcf_belongs_course_category_id', 'value' => $parent_id))
  );
  $child_posts = get_posts($childargs);
  foreach ($child_posts as $child) {
    if($child->post_title!=$post->post_title){
      echo $child->post_title.'<br/>';
    }
  }
?>

Viewing all articles
Browse latest Browse all 20145

Trending Articles