Query all posts under one taxonomy? Why is my code not working?
You haven’t specified the ‘field’ value e.g. ‘field’ => ‘slug’, http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
You haven’t specified the ‘field’ value e.g. ‘field’ => ‘slug’, http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
This should have been two different questions but anyway, I needed to use wp_list_authors for custom post type so i created this function: function get_authors_ids_by_post_type($type = null,$args=””){ if ($type === null) return; global $wpdb; $defaults = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘number’ => ”, ‘optioncount’ => false, ‘exclude_admin’ => true, ‘show_fullname’ => false, … Read more
Are you sure you are not using a custom taxonomy in your custom post type? Taxonomies for Custom Post Types have to use get_terms instead of get_category. More information on get_terms from the WordPress Codex: http://codex.wordpress.org/Function_Reference/get_terms
Take a look at this answer.
Have you made sure your CPT is using the ‘has_archive’ => true, parameter? And try something like; wp_reset_query(); if (is_post_type_archive(‘articles’)){ // do something }
In your code you are just storing an “array” in the variable $themeOne. The code you should be using to make the query is: $themeOne = new WP_Query(array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘event-themes’, ‘terms’ => ‘boat-theme’ ) ) )); The result should be an array of objects. You can then access these using … Read more
If i understand correctly, a quick solution could be using something like Widget Logic and create a custom menu for each category, then use whatever Conditional Tags applies.// such as is_category() or in_category( ‘5’ ) Or, if you don’t want to use a plug-in, you could try duplicating the widget and then adding the conditional … Read more
The page for ‘work categories’ appears as a sub-menu page of ‘Work’ CPT, after you’ve registered it correctly. These are very good posts to get started with CPTs: Thinkvitamin and Justin Tadlock. I always refer these when stuck with CPTs.
If you need to register the built in category taxonomy for a custom post type you can do this by using the priority argument when adding an init action hook. add_action( ‘init’, ‘add_category_to_post_types’, 11 ); function add_category_to_post_types() { register_taxonomy_for_object_type( ‘category’, ‘my_post_type’ ); } The third argument in the add_action() call sets a priority so most … Read more
Well, I do not know if this is quite OK, but is returning the expected results … so at the moment this it is enough for me. function my_custom_get_terms( $my_tax, $my_category, $show_all = true ){ global $wpdb; global $pagename; $query = “SELECT Count(wp_posts.ID) AS my_term_count, wp_term_taxonomy.term_taxonomy_id, wp_term_taxonomy.taxonomy, wp_terms.name, wp_terms.term_id, wp_terms.slug AS term_slug, wp_terms.term_group, wp_terms_1.slug FROM … Read more