dongqiancui9194 2014-12-20 22:58
浏览 39

Wordpress:自定义元标记列表

Using Wordpress, I am trying to write a php script that, given a certain post ID, returns all the related custom tags (also named custom terms, i. e. these words that I can use to meta describe a post and are category-independent. For example, in this page the custom terms are "passabile" and "thriller").

Is there a way to do that, possibly some WP-method that takes care of custom tag revisions?

Thanks a lot

  • 写回答

2条回答 默认 最新

  • dora0817 2014-12-20 23:04
    关注

    Use the get_post_meta() function. Say your tag is named 'custom_terms', you can do this:

    $terms = get_post_meta( $id, 'custom_terms' );
    

    If you are already on the post that you want to get that information for you can do:

    $terms = get_post_meta( get_the_ID(), 'custom_terms' );
    

    See here: http://codex.wordpress.org/Function_Reference/get_post_meta

    $terms will be an array containing all of the values.

    EDIT: If you are talking strictly about the tags of a post, you can try this:

    $tags = get_the_tags();
    

    This returns an array of tag objects that you can access by looping through them.

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害