Limiting post list by taxonomy

A simple search in codex shows how to do that : $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, ‘terms’ => ‘bob’ ) ) ); $query = new WP_Query( $args ); EDIT: do not use showposts, it’s deprecated.

How could I write a get_categories_by_year() function?

I would do this with SQL query. Doing it in PHP will be a little bit slow, I guess. This function should do the job: function get_categories_from_year($year) { $sql = “select term.* from {$wpdb->terms} term inner join {$wpdb->term_taxonomy} tax on (term.term_id = tax.term_id) inner join {$wpdb->term_relationships} relation on (tax.term_taxonomy_id = relation.term_taxonomy_id) inner join {$wpdb->posts} post … Read more

Custom taxonomy display name issue

Your registration is a bit wrong. You did not provide any of the strings necessary to label you taxonomy correctly. Pass an array to `labels’ like this: register_taxonomy( ‘location’, array( ‘post’ ), array( ‘hierarchical’ => true, ‘labels’ => array( ‘name’ => _x( ‘Genres’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Genre’, ‘taxonomy singular name’ ), … Read more

Filter posts by specific custom category and current tag

There is a descriptively named argument to WP_Query, which is what you should be using, called post__not_in which excludes any post IDs passed into it. Also, the {tax} => {term_name} pattern that you have used twice is deprecated. You should be using a tax_query argument instead. Lines like this one, strip_tags( get_the_term_list( $wp_query->post->ID, ‘buyers-club’ ) … Read more

Taxonomy Overview Page?

If all you’re trying to do is to display all post types on the taxonomy archive, then you can easily accomplish that by filtering the query at pre_get_posts. Assuming a taxonomy foobar: function wpse111033_filter_pre_get_posts( $query ) { if ( $query->is_main_query() && $query->is_tax( ‘foobar’ ) ) { $query->set( ‘post_type’, ‘any’ ); } } add_action( ‘pre_get_posts’, ‘wpse111033_filter_pre_get_posts’ … Read more

Category link redirect to custom template page instead of index.php?

Your question implies that index.php is a page to be redirected to, it isn’t, it’s purely a template file. It implies that single.php being loaded is what makes a page singular, or that loading the page.php template will give you a page, when it’s actually the other way around. I strongly recommend reading about the … Read more

Update Post Taxonomy Automatically Based On Date

You just need to set it up like this: if ( ! wp_next_scheduled( ‘check_event_status’ ) ) { wp_schedule_event( time(), ‘daily’, ‘check_event_status’ ); } add_action( ‘check_event_status’, ‘set_event_status’ ); install the Debug bar plugin and add the cron extension for it if You need some debuging info about the cron job and to be able to manually … Read more

SQL / wp_update_post: change post custom field to CPT post taxonomy

You’ve got the right idea but you are using some of the functions and function arguments incorrectly. // get all post IDs $post_ids = get_posts( array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘numberposts’ => -1, // get all posts. ‘fields’ => ‘ids’, // Only get post IDs ) ); // info: custom field ‘actor’ = … Read more