|
@@ 2810-2818 (lines=9) @@
|
| 2807 |
|
* is 'ids', an array of category ids. If `$fields` is 'names', an array of category names. |
| 2808 |
|
* WP_Error object if 'category' taxonomy doesn't exist. |
| 2809 |
|
*/ |
| 2810 |
|
function wp_get_post_categories( $post_id = 0, $args = array() ) { |
| 2811 |
|
$post_id = (int) $post_id; |
| 2812 |
|
|
| 2813 |
|
$defaults = array('fields' => 'ids'); |
| 2814 |
|
$args = wp_parse_args( $args, $defaults ); |
| 2815 |
|
|
| 2816 |
|
$cats = wp_get_object_terms($post_id, 'category', $args); |
| 2817 |
|
return $cats; |
| 2818 |
|
} |
| 2819 |
|
|
| 2820 |
|
/** |
| 2821 |
|
* Retrieve the tags for a post. |
|
@@ 2857-2866 (lines=10) @@
|
| 2854 |
|
* @return array|WP_Error Array of WP_Term objects on success or empty array if no terms were found. |
| 2855 |
|
* WP_Error object if `$taxonomy` doesn't exist. |
| 2856 |
|
*/ |
| 2857 |
|
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) { |
| 2858 |
|
$post_id = (int) $post_id; |
| 2859 |
|
|
| 2860 |
|
$defaults = array('fields' => 'all'); |
| 2861 |
|
$args = wp_parse_args( $args, $defaults ); |
| 2862 |
|
|
| 2863 |
|
$tags = wp_get_object_terms($post_id, $taxonomy, $args); |
| 2864 |
|
|
| 2865 |
|
return $tags; |
| 2866 |
|
} |
| 2867 |
|
|
| 2868 |
|
/** |
| 2869 |
|
* Retrieve a number of recent posts. |