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

Displaying Posts Attached to Custom Taxonomy Terms

The way you query for Taxonomy is deprecated, see the reference in the Codex: http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters So instead of ‘taxonomy’=> $taxonomy, you should use this: ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, ‘field’ => ‘slug’, ‘terms’ => $section->slug ) ) And make sure that $taxonomy is defined!

Permalink issues with custom taxonomies

I think that when you define custom rewrite slugs in the registration of a custom taxonomy, you still need to add custom rewrite rules. add_action(‘init’,’my_add_rewrite_rules’); function my_add_rewrite_rules() { add_rewrite_rule( ‘rights/category/(.+)/page/([0-9]{1,})/?$’, ‘index.php?post_type=rights&category=$matches[1]&paged=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘rights/category/(.+)/?$’ , ‘index.php?post_type=rights&category=$matches[1]’ , ‘top’ ); } In order to add the correct rewrite rule I would need the code of … Read more

Order custom taxonomy by date

WordPress has no an archvie for a taxonomy, but only archive for terms. E.g., you can have the url example.com/series/series-about-fish thta displays all the post in that series, but there is no an archive example.com/series/ that display the posts in all the series. Easiest way to achieve this is create a page template, create a … Read more

Is there a way to change select-list for new custom taxonomy?

If someone else stumble upon this kind of question, here’s my solution to it: (without having to mangage any metaboxes etc) add_action(‘categorycourses_add_form_fields’,’categorycourses_edit_form_fields’); add_action(‘categorycourses_edit_form_fields’,’categorycourses_edit_form_fields’); //Function only showing parent categories when editing or adding new category-courses function categorycourses_edit_form_fields() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { var level = 1; //Go down in hierarchy from level1 and remove … Read more

Adding Child Terms Programatically – No Warning but No dice either

It doesn’t work because you use wp_insert_term function incorrectly. Please read the codex manual page carefully and you will see that the second argument is not parent slug, but your custom taxonomy. So your function should look like this: create_taxonomy_record($args) { $parent_term = 0; if (!empty($args[2]) && ($parent_term = term_exists($args[2], $args[1])) { $parent_term = $parent_term[‘term_id’]; … Read more

List terms of custom taxonomy if matches other taxonomy

Your approach isn’t bad, but instead of echoing all of these out, you should store them in an array, then use array_unique to remove duplicate entries before displaying. <?php $array_out = array(); while ($the_query->have_posts()) : $the_query->the_post(); ?> $terms = get_the_terms( $post->ID, ‘city’); foreach($terms as $term){ $term_link = get_term_link($term, ‘city’); $array_out[] = ‘<a href=”‘.$term_link.'”>’.$term->name.'</a>’; } endwhile; … Read more

Query custom taxonomy for category including children

tax_query is used to get the posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. Deprecated as of Version 3.1 in favor of ‘tax_query’. tax_query (array) – use taxonomy parameters (available with Version 3.1). taxonomy (string) – Taxonomy. field (string) – Select taxonomy term by (‘id’ or ‘slug’) terms (int/string/array) – Taxonomy term(s). … Read more