Tag Info

Hot answers tagged

1

There is only one default term in Wordpress, that is the term uncategorized from the taxonomy category. This term is created when Wordpress is first installed. This term's ID will always be 1 if it is not altered in any other way by some custom code from a custom theme or plugin. Term ids, like post ids, are very reliable and does not change within a ...


1

Here's the code, rewriten from posts and categories to custom post types and taxonomy terms. Thanks to @PieterGoosen for providing the first version. http://pastebin.com/xKBepGQz <?php $args = array( 'post_type' => 'produkty', // your CTP name 'meta_key' => 'produkt_nowosc', // custom meta key for displaying, in my case: the newest ...


1

Most likely the problem comes from: $terms = get_the_terms( $post->ID, $args['taxonomy'] ); i.e. you have to make sure it's not false or WP_Error object. You should also check the output of: var_dump( $args ); Try for example: if( ! is_array( $terms ) ) return $output; or if( ! $terms || is_wp_error( $terms ) ) return $output; ...


1

Your problem is that your trying to access taxonomy data before it is registered. This doesn't work: add_action('init', 'json_handler'); function json_handler(){ $categories = get_terms( 'my_cat', 'orderby=count&hide_empty=0' ); if( ! is_wp_error( $categories ) ) { // encode the $categories array as json print_r( json_encode( ...



Only top voted, non community-wiki answers of a minimum length are eligible