Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_wp_preview_terms_filter ›

Seit3.6.0
Veraltetn/v
_wp_preview_terms_filter ( $terms, $post_id, $taxonomy )
Zugriff:
  • private
Parameter: (3)
  • (array) $terms
    Erforderlich: Ja
  • (int) $post_id
    Erforderlich: Ja
  • (string) $taxonomy
    Erforderlich: Ja
Gibt zurück:
  • (array)
Definiert in:
Codex:

Filters terms lookup to set the post format.



Quellcode

function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
	if ( ! $post = get_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();
	} elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) {
		$terms = array( $term ); // Can only have one post format
	}

	return $terms;
}