Wrap a chosen category name with div
get_term_by returns an object by default, so you could output the term name using <?php $term = get_term_by(‘name’, ‘foo’, ‘category’); echo “<div>$term->name</div>”; ?>
get_term_by returns an object by default, so you could output the term name using <?php $term = get_term_by(‘name’, ‘foo’, ‘category’); echo “<div>$term->name</div>”; ?>
In your update_count_callback function do a check for $post->post_status and don’t increment your count if post_status is not private. See this excellent answer on writing a custom update_count_callback callback function. Edit: Misread the question. To override the existing default for the category taxonomy you can create a function that overrides the global $wp_taxonomies variable function … Read more
I got the same need, personally I used wp_set_object_terms after a WP_Query resquest on all of my custom post type. I suppose you could replace my_custom_type with post in the following quote of my code: $my_query = array( ‘post_type’ => array( ‘post’, ‘my_custom_type’ ) ); $the_query = new WP_Query( $my_query ); while ( $the_query->have_posts() ) … Read more
According to template hierarchy you have to create the template taxonomy-photographyCategories.php
Same base slug for CPT post and CPT taxonomy terms
Since wp_set_post_terms() does not accept hierarchy for it, you will first have to check if terms exist already, create them using wp_insert_term() if not and only then assign to post. Note that there had been (don’t know current state) some cache related bugs with doing such things on the fly, see Inserting terms in an … Read more
Add custom taxonomy to default category taxonomy?
How to modify default taxonomy field to a single text field?
One way to show a specific post always first is to add a sorting loop between your post query and rendering loop. For example, $my_posts = array(); // do your query first to get the posts $sorted_posts = array(); // helper var to store sorted posts // The sorting loop foreach ( $my_posts as $post … Read more
The problem is the use of the php function list. If successful, wp_insert_term returns something of the form: array(2) { [“term_id”]=> int(307) [“term_taxonomy_id”]=> int(325) } You can’t use list with this as list only works for numerical arrays. Instead try extract instead: extract($result); echo “<p>The term <i>{$term_name}</i> under the <i>{$term_taxonomy}</i> taxonomy has been added into … Read more