Print child category slug nicename
seems nobody understood ‘my question’, so I solved it myself here is the code for getting the slug I needed <?php $cat = get_term_by(‘name’, single_cat_title(”,false), ‘category’); echo $cat->slug; ?>
seems nobody understood ‘my question’, so I solved it myself here is the code for getting the slug I needed <?php $cat = get_term_by(‘name’, single_cat_title(”,false), ‘category’); echo $cat->slug; ?>
If you made any modifications to your code, you might want to flush your permalinks. Go to Settings -> Permalinks, this will flush them. Then head back to your archives page. If this doesn’t help, show us some code please.
Use wp_list_categories Here’s all the parameters <?php $args = array( ‘show_option_all’ => ”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘style’ => ‘list’, ‘show_count’ => 0, ‘hide_empty’ => 1, ‘use_desc_for_title’ => 1, ‘child_of’ => 0, ‘feed’ => ”, ‘feed_type’ => ”, ‘feed_image’ => ”, ‘exclude’ => ”, ‘exclude_tree’ => ”, ‘include’ => ”, ‘hierarchical’ => 1, … Read more
EDIT When you decided to unaccept my answer and change your question in the comments to my answer I was already in bed. Please consider @kaiser comment next time when asking a question. For the purpose of my answer, here is your comment i am having problem.. actually i want to show order by alphabet … Read more
You can use the wp_list_categories function with the taxonomy argument product_cat: <ul class=”categories”> <?php wp_list_categories( ‘taxonomy=product_cat&title_li=’ ) ?> </ul>
It will generate the structure as you have asked for. if (is_category()) { $this_category = get_category($cat); if (get_category_children($this_category->cat_ID) != “”) { echo ‘<div id=”catlist”><ul>’; $childcategories = get_categories(array( ‘orderyby’ => ‘name’, ‘hide_empty’ => false, ‘child_of’ => $this_category->cat_ID )); foreach($childcategories as $category) { echo ‘<li class=”sub-cat”>’; echo ‘<a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . … Read more
Calling WP_Query three times isn’t too good for performance, as it will make three queries to the database. The way you’re currently approaching this seems like the proper (and fastest) way in may opinion. However, you should be calling $category_posts->rewind_posts() after each while-loop to reset WP_Query‘s loop to the first post. Furthermore, your current way … Read more
Create a file date.php in your active theme and use below code, you may need to polish this code as per your requirement: <div id=”content” class=”post-archive<?php echo $content_class; ?>”> <?php if ( have_posts() ) : ?> <header class=”archive-header”> <h3 class=”archive-title”> <?php if ( is_day() ) : ?> <?php printf( __( ‘Daily Archives: %s’ ), ‘<span>’ … Read more
get_the_time(‘U’) returns $string. You cannot subtract a string from an integer function new_badge(){ if ( (time() – strtotime ( get_the_time( ‘U’ ) ) ) <= (3*86400)) { echo ‘<div class=”new”></div>’; } }
To get children with get_terms() you have two options. You can either use the argument parent, which will only get direct children, so only one level down; or you use child_of, which gets all descendants, meaning until last level down. Both parent and child_of need an integer as value, which would in both cases be … Read more