Switch language

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




wp_get_post_categories [ WordPress Function ]

wp_get_post_categories ( $post_id = 0, $args = array() )
Parameters:
  • (int) $post_id Optional. The Post ID.
  • (array) $args Optional. Overwrite the defaults.
Uses:
Returns:
  • (array)
Defined at:



Retrieve the list of categories for a post.

Compatibility layer for themes and plugins. Also an easy layer of abstraction away from the complexity of the taxonomy layer.

Source


<?php
function wp_get_post_categories$post_id 0$args = array() ) {
    
$post_id = (int) $post_id;

    
$defaults = array('fields' => 'ids');
    
$args wp_parse_args$args$defaults );

    
$cats wp_get_object_terms($post_id'category'$args);
    return 
$cats;
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

0 User Note(s)

None yet. Be the first!

Add New ...



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