How to use wp_category_checklist()?

Here is the answer I ended up with: $select_cats = wp_dropdown_categories( array( ‘echo’ => 0 ) ); $select_cats = str_replace( “name=”cat” id=”, “name=”cat[]” multiple=”multiple” id=”, $select_cats ); echo $select_cats; It displays a list of my categories that can be multi-selected as per my question. It’s a hack of wp_dropdown_categories, but it works.

get all sub categories without specify any category

You could use get_categories(). Returns an array of category objects matching the query parameters. Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax. // Fetch parent categories $parent_categories = get_categories( ‘parent=0’ ); foreach ( $parent_categories as $parent_category ) { // Fetch child categories $args = … Read more

How to modify category.php to list posts alphabetically?

Try to do all theme modifications in functions.php whenever possible. It keeps the theme files clean and uncluttered. Here’s an example using the pre_get_posts action: function order_category_archives( $query ) { if ( is_category() && $query->is_main_query() ){ // is_category() can specify a category, if necessary $query->set( ‘orderby’, ‘title’ ); $query->set( ‘order’, ‘ASC’ ); } } add_action( … Read more

Add Class While on Current Post; wp_list_categories

very similar approach to the answer by @AndrettiMilas: add_filter(‘wp_list_categories’,’style_current_cat_single_post’); // filter to add the .current-cat class to categories list in single post function style_current_cat_single_post($output) { if( is_single() ) : global $post; foreach ( get_the_category($post->ID) as $cat ) { $cats[] = $cat->term_id; } foreach($cats as $value) { if(preg_match(‘#item-‘ . $value . ‘”>#’, $output)) { $output = … Read more

Direct link to category?

There is a function called get_category_link() which might be helpful for you. This will be able to generate an appropriate link without having to hard-code it, except for the category name or ID. Examples from the WordPress Codex: <?php // Get the ID of a given category $category_id = get_cat_ID( ‘Category Name’ ); // Get … Read more

Allow dot in wordpress permalinks (only for categories)

Well in case you need to change look of generated permalinks take a look to sanitize_title_with_dashes function which is one of filters of the sanitize_title hook filters. If that only one request for this filter (avoid replacing .) you can copy/paste this function with a same name and remove original reference and add new. remove_filter(‘sanitize_title’, … Read more

How to set up Author archives with sub category URL

As I mentioned in my comment, you can use add_rewrite_endpoint to accomplish this. First, add the endpoint: function wpa_author_endpoints(){ add_rewrite_endpoint( ‘liked-posts’, EP_AUTHORS ); } add_action( ‘init’, ‘wpa_author_endpoints’ ); After flushing rewrite rules (visit your Settings > Permalinks page in admin), author URLs can now be appended with /liked-posts/. Next, add a filter to author_template to … Read more

wp_nav_menu not highlighting the current category when viewing a single post

There are several built-in CSS classes that come with the wp_nav_menu. In your case, you are looking for something like a current category class, which is not included. But we can easily add that to the CSS classes: function wpse_134409_current_category_class($classes, $item) { if ( is_single() && ‘category’ === $item->object && in_array($item->object_id, wp_get_post_categories($GLOBALS[‘post’]->ID)) ) $classes[] = … Read more

Add multiple=”multiple” attribute to categories dropdown

Take a look at the source of wp_dropdown_categories(). It uses walk_category_dropdown_tree() to render the output. Right after that you have a filter named wp_dropdown_cats that allows altering the final MarkUp: $output = apply_filters( ‘wp_dropdown_cats’, $output ); You could now use a Regex and preg_replace or parse it using DOMDocument, etc. Keep in mind that you … Read more