Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_the_terms [ WordPress Function ]

get_the_terms ( $id, $taxonomy )
Parameters:
  • (int) $id Post ID.
  • (string) $taxonomy Taxonomy name.
Returns:
  • (array|bool) False on failure. Array of term objects on success.
Defined at:



Retrieve the terms of the taxonomy that are attached to the post.

Source


<?php
function get_the_terms$id$taxonomy ) {
    global 
$post;

     
$id = (int) $id;

    if ( !
$id ) {
        if ( empty( 
$post->ID ) )
            return 
false;
        else
            
$id = (int) $post->ID;
    }

    
$terms get_object_term_cache$id$taxonomy );
    if ( 
false === $terms ) {
        
$terms wp_get_object_terms$id$taxonomy );
        
wp_cache_add($id$terms$taxonomy '_relationships');
    }

    
$terms apply_filters'get_the_terms'$terms$id$taxonomy );

    if ( empty( 
$terms ) )
        return 
false;

    return 
$terms;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics