post count is wrong when using same taxonomy for 2 different CPT
This is a known issue see Custom taxonomy count includes draft & trashed posts. It might not be fixed in version 3.2 but most likely in the next version.
This is a known issue see Custom taxonomy count includes draft & trashed posts. It might not be fixed in version 3.2 but most likely in the next version.
Short answer: No. When you’re working with SEO, there are three things to take into account: Site content Site meta descriptions Site findability (it’s a word, I swear!) Site Content Search engines will parse your site’s content looking for content and keywords. Create good, useful content and it will be fetched, parsed, and recorded appropriately. … Read more
Use get_ancestors() and count the returned array: that’s the number of ancestors a term has. /** * Count a term’s ancestors. * * @param int $term_id * @param string $taxonomy * @return int */ function wpse_57512_count_ancestors( $term_id = FALSE, $taxonomy = FALSE ) { if ( FALSE === $term_id and ! empty ( get_queried_object()->taxonomy ) … Read more
You’d write a script to loop through a file you created with the data, and process each line one at a time. Inside the loop you’d have code like the following. You would, of course, replace my example values Scotland, Glasgow, its description and its slug with variables representing the data for the row being … Read more
This can be done with jQuery. In this example, the modifier is printed when editing an existing post (admin_head-post.php) and when writing a new one (admin_head-post-new.php). There’s a condition to check for the correct post type, as this hooks work with posts, pages and custom post types. The “Most used” tab is being hidden. To … Read more
So, to answer my own question: I haven’t found any solution inside wp_insert_post_data. I suspect that the problem is connected to the fact that when wp_insert_post_data is executed the post in question is not yet in the database. And albeit I didn’t manage to find it in taxonomy.php, it is logical to assume that the … Read more
Per your comment (and hopefully an edit to the question) : I did it like so: foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name, array( ‘orderby’ => ‘name’, ‘hide_empty’ => 0) ); Formatted: foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name, array( ‘orderby’ => ‘name’, … Read more
Use the hooks added_term_relationship and deleted_term_relationships. These only fire when the relationship changes, as opposed to set_object_terms which always fires: function wpse_181090_object_terms_updated( $object_id ) { static $did = array(); // This function might fire multiple times for the same object, ensure it only runs once if ( ! isset( $did[ $object_id ] ) ) { … Read more
get_terms() doesn’t have built-in feature that excludes draft posts because it keeps track of only total posts term is attached to. I made a quick search and found this snippet but be warned: It affects all get_terms() functions on your site (I excluded admin area) There’s a SQL query in foreach loop – it will … Read more
get_the_terms() is probably returning false. Do a print_r($event_type_term) to see what you have in it. From: http://codex.wordpress.org/Function_Reference/get_the_terms Array of term objects on success. False if no terms are found in the given taxonomy and a wp_error object if an invalid taxonomy is entered.