【问题标题】:wordpress title and category as resultwordpress 标题和类别作为结果
【发布时间】:2014-04-18 09:49:52
【问题描述】:

请看下面的代码!它来自 wordpress 插件。 我怎样才能得到结果
$search = 帖子标题(空格)类别名称

    // Relation: Post title.
if( $relation === 'posttitle' ) {

  global $post;

  $search     = ( isset( $post->post_title ) ) ? $post->post_title : '';

}

它来自一个 wordpress 插件相关的 YouTube 视频。我想根据标题和类别向您展示电子管! 这个插件没有两个选项!

https://wordpress.org/plugins/related-youtube-videos/

related-youtube-videos\lib\RelatedYouTubeVideos\API.php

提前致谢!

【问题讨论】:

标签: php wordpress youtube


【解决方案1】:

您可以使用get_the_category()函数获取类别名称

$category = get_the_category($post->ID);
$search = ( isset( $post->post_title ) ) ? $post->post_title . ' ' . $category[0]->cat_name : '';

【讨论】:

  • 但是我如何合并标题和类别名称,以便我获得价值标题 - $search 的类别
  • 我已经编辑了我的答案以满足您的要求。希望这会有所帮助
猜你喜欢
  • 2012-07-12
  • 1970-01-01
  • 1970-01-01
  • 2019-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多