• Resolved Archie Makuwa

    (@archie22is)


    Hi guys,

    I have the following code which returns the followig array:

    5 =>
        object(stdClass)[14]
          public 'term_id' => string '62' (length=2)
          public 'name' => string 'IT & Telecommunications' (length=27)
          public 'slug' => string 'it-and-telecommunications' (length=25)
          public 'term_group' => string '0' (length=1)
          public 'term_taxonomy_id' => string '151' (length=3)
          public 'taxonomy' => string 'services' (length=8)
          public 'description' => string '' (length=0)
          public 'parent' => string '0' (length=1)
          public 'count' => string '0' (length=1)

    However whenever I loop through the returned array list using the following code:

    $mycateg = get_terms( 'services', array(
    							'parent' => 0,
    							'oderby' => 'name',
    							'hide_empty' => 0
    							)
    						);
    					echo "test";
    
    					foreach ($mycateg as $categ) {
    						echo $mycateg->name;
    					}

    I get no output at all – only a null. what is the correct way to create output?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Loop through array’ is closed to new replies.