
如何提升WordPress站内搜索速度及结果准确率
wp_get_post_terms ( $post_id = 0, $taxonomy = 'post_tag', $args = array() )
wp_get_post_terms: 这个函数用于检索与特定文章相关的术语(类别、标签等)。它把文章的ID和分类法作为参数,并返回一个术语对象的数组,每个对象都包含有关术语的信息。
检索一个文章的术语。
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) { $post_id = (int) $post_id; $defaults = array( 'fields' => 'all' ); $args = wp_parse_args( $args, $defaults ); $tags = wp_get_object_terms( $post_id, $taxonomy, $args ); return $tags; }