wp_list_categories, Add class to all list items with children

jQuery solution: You could try this if you want to use jQuery: <script> jQuery(document).ready(function($) { $(‘li.cat-item:has(ul.children)’).addClass(‘i-have-kids’); }); </script> to add the class i-have-kids to all the li parents that include the items ul.children, within the HTML generated from wp_list_categories(). Category walker solution: You could take a look at the Walker_Category class in /wp-includes/category-template.php and extend … Read more

How can I remove links from the function “get term list”?

It may be easier to just write the list manually, something like: <?php $terms = wp_get_post_tags( $post->ID ); //For custom taxonomy use this line below //$terms = wp_get_object_terms( $post->ID, ‘people’ ); foreach( $terms as $term ) $term_names[] = $term->name; echo implode( ‘, ‘, $term_names );

Filter blog archive by category in URL

Even if default posts are stored in same table but they have different behavior and different characteristics. CPT has post type archive but default post type archived is called as blog and the taxonomy filter is called as tag/category archive. You can access the category/tag archive using For categories: /?cat={category_id} //e.g. ?/cat=5 For tags: /?tag={tag_slug} … Read more

Remove “-2” from a Toolset Types URL with the same post name

It can be done by using the request filter. Something like this function alter_the_query($request) { return array(‘page’ => 1, ‘pagename’ => null); } add_filter(‘request’,’alter_the_query’); Here it forces display of post 1, though of course you will want to do a query to determine the ID. For that, it might prove easiest to first parse the … Read more

What hooks/filters are there to alter selected terms on post save?

It is always ‘save_post’ (or ‘wp_insert_post’ immediately after this). In $_POST[‘tax_input’] you will find all the terms for all taxonomies associated with the current post. Example: ‘tax_input’ => array ( ‘location’ => array ( 0 => ‘0’, ), ), To change the terms you have to call wp_set_post_terms( $post_ID, $tags, $taxonomy ); manually, just changing … Read more