Custom post not appearing under custom taxonomy category
in_category is only for the built-in category taxonomy. If you want to check a custom taxonomy term, use has_term: if ( has_term( ‘double portrait’, ‘twin’ ) ) {
in_category is only for the built-in category taxonomy. If you want to check a custom taxonomy term, use has_term: if ( has_term( ‘double portrait’, ‘twin’ ) ) {
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.
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
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
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
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
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
You are passing strings as the second parameter $terms and you have a hierarchical taxonomy. Per the Codex: For hierarchical terms (such as categories), you must always pass the id rather than the term name to avoid confusion where there may be another child with the same name. If you follow the source, you will … Read more
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
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