WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How To Display Specific Terms (2 posts)

  1. dorich
    Member
    Posted 10 months ago #

    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

  2. dorich
    Member
    Posted 10 months ago #

    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.

Reply

You must log in to post.

About this Topic