Tag Info

Hot answers tagged

2

Try this <a href="/category/<?php foreach((get_the_category()) as $category) { echo $category->slug . ' '; } ?>"> Hope this helps.


2

I think it will be easier to make use of the category slug, and not the name. It is already in lowercase and hyphen separated if you have more that one word. The problem with using the name and adding hyphens is that you will not get a match and most probably just 404. %20 is how blank spaces is encoded in a URL. You can just replace $category->cat_name ...


1

You could use this simple function call which returns either TRUE or FALSE depending on if $children is an empty array or not. function category_has_children( $term_id = 0, $post_type = 'post', $taxonomy = 'category' ) { $children = get_categories( array( 'child_of' => $term_id, 'type' => $post_type, 'taxonomy' => $taxonomy ) ); return ( ...


1

Looking at the source code for wp_get_archives(), there is a filter called getarchives_join which you can use to restrict wp_get_archives() to a specific category You also need to get the current category ID, which is easy, simply use get_queried_object_id() You can try something like this to display archives for the currently viewed category add_filter( ...


1

2 Years later, there is a WordPress plugin that does this. Checkout "Featured Images for Categories" https://wordpress.org/plugins/featured-images-for-categories/


1

Yes, there is. Paste this in your function.php add_action('pre_get_posts','wpse_175699_alphabetical_order'); function wpse_175699_alphabetical_order($query) { if (is_category()) { $query->set('orderby', 'title'); $query->set('order', 'ASC'); } }


1

I believe, most obvious choice would be to create two categories "Fall-Winter" and "Spring-Summer" and put four other categories in both of them. Your URLs would be like this /category/fall-winter /category/fall-winter/formal-wear /category/fall-winter/night-wear Now, to list the formal wear for both fall-winter and spring-summer on page, we have few ...


1

You can make use of the the_content filters to apply markup to get_the_content() $content = get_the_content(); echo apply_filters( 'the_content', $content ); You'll need to do the same for get_the_title() where you would use the_title filters instead of the_content Just another note on your code, remember to reset each of your custom loops with ...



Only top voted, non community-wiki answers of a minimum length are eligible