single_cat_title equivalent for custom taxonomy?
For custom taxonomy terms, use single_term_title Displays or returns the term title for the current page. Alternatively you can make use of echo get_queried_object()->name
For custom taxonomy terms, use single_term_title Displays or returns the term title for the current page. Alternatively you can make use of echo get_queried_object()->name
I managed to sort this using: <?php $category_ids = get_all_category_ids(); ?> <?php $args = array( ‘orderby’ => ‘slug’, ‘parent’ => 0, ‘taxonomy’ => ‘servicecats’ ); $categories = get_categories( $args ); foreach ( $categories as $category ) { echo ‘<li><img src=””/><a href=”‘ . get_category_link( $category->term_id ) . ‘” rel=”bookmark”>’ . $category->name . ” . ” . … Read more
I needed something like this for a client site, they wanted to add tags to all their products, but I didn’t want them just making up new tags, I wanted to give them a list of tags to start with. vancoder’s answer provided the key I needed to get this done: the ‘hide_empty’ attribute. What … Read more
What about using: echo get_the_term_list( $post->ID, ‘artist-genre’, ‘<li>’, ‘,</li><li>’, ‘</li>’ ); instead, to generate the HTML list? Or simply: the_terms( $post->ID, ‘artist-genre’, ‘<li>’, ‘,</li><li>’, ‘</li>’ ); that’s a wrapper for get_the_term_list(). Also notice that you’re missing the is_wp_error() check, in your code snippet, because wp_get_post_terms() can return the WP_Error object, for an unknown taxonomy. But … Read more
Drop your custom query and go back to the default loop. Never replace the main query on the home page or any kind of archive page with a custom query. Use pre_get_posts to alter the main query variables before the main query runs Your taxonomy archive page should look like this if ( have_posts() ) … Read more
Figured it out! $state_tax_args = array( ‘post_type’ => ‘products’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product-line’, ‘field’ => ‘slug’, ‘terms’ => $pl_slug // provided at page load ), ), ); $state_tax_query = new WP_Query( $state_tax_args ); // counter to build array $i=0; if ( $state_tax_query->have_posts()) { $state_term_list=”<select class=”form-control” id=”inputStateSelect” … Read more
The second parameter to wp_set_object_terms() takes an array, integer, or string. (array/int/string) (required) The slug or id of the term (such as category or tag IDs), will replace all existing related terms in this taxonomy. To clear or remove all terms from an object, pass an empty string or NULL. Integers are interpreted as tag … Read more
You custom post type is NOT public. Add following lines to your register_post_type array ‘public’ => true, ‘publicly_queryable’ => true,
Maybe try wp_insert_term once the plugin has been enabled: https://codex.wordpress.org/Function_Reference/wp_insert_term I.e. wp_insert_term( ‘Male’, // the term ‘dog_sex’, // the taxonomy array( ‘slug’ => ‘male’, ) );
Simple way: In my plugins, register_activation_hook always have a line like delete_option(‘rewrite_rules’); when I’m creating custom post types. WordPress will properly rebuild them. I’ve provided a detailed answer Also another inspiring answer here