@@ 2714-2722 (lines=9) @@ | ||
2711 | * 'all_with_object_id', an array of WP_Term objects will be returned. If `$fields` |
|
2712 | * is 'ids', an array of category ids. If `$fields` is 'names', an array of category names. |
|
2713 | */ |
|
2714 | function wp_get_post_categories( $post_id = 0, $args = array() ) { |
|
2715 | $post_id = (int) $post_id; |
|
2716 | ||
2717 | $defaults = array('fields' => 'ids'); |
|
2718 | $args = wp_parse_args( $args, $defaults ); |
|
2719 | ||
2720 | $cats = wp_get_object_terms($post_id, 'category', $args); |
|
2721 | return $cats; |
|
2722 | } |
|
2723 | ||
2724 | /** |
|
2725 | * Retrieve the tags for a post. |
|
@@ 2758-2767 (lines=10) @@ | ||
2755 | * @return array|WP_Error List of post terms or empty array if no terms were found. WP_Error object |
|
2756 | * if `$taxonomy` doesn't exist. |
|
2757 | */ |
|
2758 | function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) { |
|
2759 | $post_id = (int) $post_id; |
|
2760 | ||
2761 | $defaults = array('fields' => 'all'); |
|
2762 | $args = wp_parse_args( $args, $defaults ); |
|
2763 | ||
2764 | $tags = wp_get_object_terms($post_id, $taxonomy, $args); |
|
2765 | ||
2766 | return $tags; |
|
2767 | } |
|
2768 | ||
2769 | /** |
|
2770 | * Retrieve a number of recent posts. |