Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a problem to get the term of custom posts list. I have 2 taxonomies on my custom post type. one of them is "visa_processing". and I am trying to create a list (table, tr, td) "Name1, Name2, passport num, processing."

"processing" is a term and each different.

I need to get "processing" term on list for each posts.

ex) John, Smith, K009923, waiting Price, Mark, K009923, failed Jordan, MC, K009923, issued

"applied, waiting, failed, issued" <--- these are terms of the taxonomy "visa_processing".

But terms are not showing or printed "Array". how can I fix it?

 $args = array(
'post_type'   => $post_type,
'numberposts' => $limit,
'post_status' => $status,
);
$posts = get_posts( $args );
if( count($posts) ):
$return .= '<table>';
foreach( $posts as $post ): setup_postdata( $post );

/** get meta values and replace **/
$getPassport = get_post_meta( get_the_ID(), '_Passport', true );
$getPassport_replaced = substr_replace($getPassport, "*", 3).'*****';

$getName1 = get_post_meta( get_the_ID(), '_Name1', true );
$getName2 = get_post_meta( get_the_ID(), '_Name2', true );
$getName2_replaced = substr_replace($getName2, "*", 3).'***';
//$getNames = get_the_title();  // 전체 이름 : 사용안함

//$processing = get_the_terms( get_the_ID(), 'visa_processing', array("orderby"=>"term_order"));
//$processing = wp_get_post_terms( get_the_ID(), 'visa_processing');
//$processing = wp_get_object_terms( get_the_ID(), 'visa_processing' );
//echo get_the_ID();

//$terms = get_the_terms();   print_r($terms);


  $return .= '<tr><td>' . $getName1 .'&nbsp;'. $getName2_replaced .'</td>  <td>'.$getPassport_replaced.'</td><td>'.$processing.'</td></tr>';

 endforeach; wp_reset_postdata();
   $return .= '</table></div>'; //#recent_visas
 else :
   $return .= '<p>No posts found.</p>';
 endif;

return $return;

share|improve this question
add comment

1 Answer

or printed "Array"

That is your clue. Array indicates something is being returned, you just need to make use of it.

Try var_dump($processing) and see what the array contains. In my plugins I have a functioned called example_var_dump(); and it is setup to use

 before the var_dump() line and 
after it. This displays arrays in a readable fashion.

Plus I have a global variable for debugging mode. If that is set to false, my example_var_dump() function does nothing. This is to avoid dumping information in a released version after forgetting to removing var_dump() in complex scripts. Just a tip.

share|improve this answer
    
array(1) { [15]=> object(stdClass)#494 (10) { ["term_id"]=> string(2) "15" ["name"]=> string(6) "waiting" ["slug"]=> string(18) "abceodkd" ["term_group"]=> string(1) "0" ["term_taxonomy_id"]=> string(2) "15" ["taxonomy"]=> string(15) "visa_processing" ["description"]=> string(0) "" ["parent"]=> string(1) "0" ["count"]=> string(1) "2" ["object_id"]=> string(3) "488" } } I got like this from var_dump($processing). I found "waiting" on name. so I tried echo $processing["name"]; but it says "bool(false)". I am sorry for my poor php. how can I fix it? –  pulla Aug 17 '13 at 8:14
    
opps. it's not saying "bool(false)". it comes null. –  pulla Aug 17 '13 at 8:18
    
Hey, we all start somewhere. That object is "stdClass". Try this... echo $processing->name; your going to make excellent progress in future once you learn these basics ;) –  WebTechGlobal Aug 17 '13 at 19:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.