我创建了一个自定义的帖子类型面试,我还创建了自定义的帖子分类法面试\\u类别,自定义分类法有一些术语,如学生、教师等。我试图在档案采访中得到术语的名称。php,但它会显示通知,如未定义的变量post,并试图获取非对象的属性。我的档案采访代码是:
<?php if(have_posts()):
// $tax = $wp_query->get_queried_object();?>
<section class="interview_main_wrapper">
<div class="interview_head dropdown">
<button class="black-btn" type="button">
<a id="dropdownMenu1" class="auto_drop" data-toggle="dropdown">
<?php // Get terms for post
$terms = get_the_terms( $post->ID , \'dastak_interview_category\' );
// Loop over each item since it\'s an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->slug ;
// Get rid of the other data stored in the object, since it\'s not needed
unset($term);
} }else{
echo \'All Interview\';
} ?></a>
我知道这个名字,但每次都会看到通知。