WordPress开发者和主题制作者的搜索引擎



_wp_preview_terms_filter ›

Since3.6.0
已弃用n/a
_wp_preview_terms_filter ( $terms, $post_id, $taxonomy )
访问:
  • private
参数: (3)
  • (array) $terms
    Required: Yes
  • (int) $post_id
    Required: Yes
  • (string) $taxonomy
    Required: Yes
返回:
  • (array)
定义在:
文档:

Filters terms lookup to set the post format.



源码

function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
	$post = get_post();
	if ( ! $post ) {
		return $terms;
	}

	if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) {
		return $terms;
	}

	if ( 'standard' == $_REQUEST['post_format'] ) {
		$terms = array();
	} else {
		$term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' );
		if ( $term ) {
			$terms = array( $term ); // Can only have one post format
		}
	}

	return $terms;
}