• Resolved dorich

    (@dorich)


    This may be a syntax problem but if so I can’t see the problem.

    I want to select specific terms of a custom taxonomy and display their names. I’m having a problem with the selection process in the following code.

    $taxonomy = ‘chapters’;
    echo(“Test Term Display “);
    $args1=array(
    ‘include’=> array(74,76
    )
    );
    $chaptertitles=get_terms( ‘chapters’, $args1 );
    $count1 = count($chaptertitles);
    echo($count1);
    if ( $count1 > 0 ){
    echo ”

      “;
      foreach ( $chaptertitles as $chaptertitle ) {
      echo ”

    • Chapter Title:” . $chaptertitle->name . “
    • “;

    }
    echo “
    “;
    }
    This returns zero for $count1.

    However, if I remove the arguements so that the default conditions apply then I get all the terms returned.

    This suggests that my syntax is incorrect for $args1 but I can’t see any errors.

    I’d appreciate any suggestions on how to get this working.

    Thx

Viewing 1 replies (of 1 total)
  • Thread Starter dorich

    (@dorich)

    The solution to the problem is that by default terms having no posts are not displayed. This can be changed by adding “hide_empty”=>0 to the parameter list.

Viewing 1 replies (of 1 total)
  • The topic ‘How To Display Specific Terms’ is closed to new replies.