如何获得帖子的所有条款

时间:2013-09-05 作者:sublimelaconic

以下是我目前的代码:

$terms = wp_get_post_terms($event->ID, \'speakers\', array("fields" => "all"));
print_r($terms);
它显示以下内容:

Array ( 
   [0] => stdClass Object ( 
          [term_id] => 64 
          [name] => Apostle Dr. N Suppaya 
          [slug] => apostle-dr-n-suppaya 
          [term_group] => 0 
          [term_taxonomy_id] => 64 
          [taxonomy] => speakers
          [description] => Apostle Dr. N Suppaya, God called him to the ministry, anointed him and told him to bring love, joy and peace of Jesus Christ to the world. In 1986, Apostle Suppaya received the Apostolic calling from God when God told him to build a Church which will be an instrument in building the Kingdom of God through evangelism and missions to the unsaved. This gave the birth to Jesus Lives Church. God has been blessing him with great miracles to testify the glory of God through his ministerial exposures. 
          [parent] => 0 
          [count] => 2 ) 

   [1] => stdClass Object ( 
          [term_id] => 61 
          [name] => Pastor Lynette Teo 
          [slug] => ps-lynette-teo
          [term_group] => 0
          [term_taxonomy_id] => 61
          [taxonomy] => speakers
          [description] => Pastor Lynette Teo graduated from RHEMA Bible Training Centre Singapore is married to Kevin and both are currently instructors at RBTCS, with a strong passion to teach and equip believers in Singapore and Asia in order to further God’s purposes and plans in advancing His Kingdom. They have also ministered in bible schools and churches in various parts of Asia including Malaysia, Indonesia, Thailand and Myanmar. They serve as leaders in their local church and are actively involved in areas of mentoring and discipleship. Lynette also serves in the prayer as well as worship ministries.    
          [parent] => 0 
          [count] => 1 
   ) 
) 
我怎样才能呼应名称和描述?

1 个回复
最合适的回答,由SO网友:jhussey 整理而成

要打印每个术语,可以循环遍历每个对象并回显名称和描述

foreach ($terms as $theterm) {    
    echo $theterm->name . " " . $theterm->description;
}
这就是你要找的吗?

[编辑]更新了答案

结束

相关推荐

如何在不更改wp-config.php或更改媒体设置的情况下将媒体文件保存在自定义文件夹下

我想上传一个独特的文件夹中的图像。然后检索保存在服务器上的此图像的路径,如http://example.com/wp-content/uploads/myimages/image1.jpg 现在,我想将此URL保存在一篇文章中,并将自定义字段作为URL。我将定期覆盖帖子并替换相应的图像,所以我不想在我的服务器上保留与以前帖子(已删除帖子)相关的图像(否则会增加服务器上的内存)。我想从中删除所有图像myimages 文件夹我不想更改上载的默认路径。以下是我创建帖子的代码:$new_post = a