how to define category loop last class in the third

You can do with php modulus % operator. Lets work with your code. <?php if ( have_posts() ) : ?> <?php twentyeleven_content_nav( ‘nav-above’ ); ?> <?php /* Start the Loop */ ?> <?php $count = 1; ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * … Read more

Second level subcategory

Found the solution! 🙂 $taxonomies = array(CUSTOM_CAT_TYPE); foreach($taxonomies as $tax) { $args = array( ‘orderby’ => ‘name’, ‘show_count’ => 1, ‘pad_counts’ => 1, ‘hierarchical’ => 1, ‘hide_empty’ => 0, ‘taxonomy’ => $tax, ); wp_dropdown_categories( $args ); } Thanks for helping out!

Style wp_list_categories

My suggestion. $categories = get_the_category(); $output=””; if($categories) { $output = “<ul>”; foreach($categories as $category) { $output .= ‘<li><div class=”btn-standard”><a href=”‘.get_category_link( $category->term_id ).'” title=”‘ . esc_attr( sprintf( __( “View all posts in %s” ), $category->name ) ) . ‘”>’.$category->cat_name.'</a></div></li>’; } $output .= “</ul>”; } echo $output; You can check Codex for more reference.

How to show only one category in breadcrumb navigation

get_the_category() function used to retrieve categories array of a post, and array_shift() function used to get the first item of an array. You possibly need this – function ux_breadcrumbs() { if (!is_home()) { echo ‘<a href=”‘; echo get_option(‘home’); echo ‘”>’; bloginfo(‘name’); echo “</a> » “; if (is_category() || is_single() ) { if( is_category() ) { … Read more

Set Current Category to Active in category.php

You can filter the output on wp_list_categories: add_filter( ‘wp_list_categories’, function( $html ) { return str_replace( ‘ current-cat’, ‘ active’, $html ); }); If you are stuck with an outdated PHP version … find a better web hosting. In the mean time, you can try this: add_filter( ‘wp_list_categories’, ‘replace_current_cat_css_class’ ); function replace_current_cat_css_class( $html ) { return … Read more

Automatically set default password to all posts in a specific category

This should do what you want: add_filter(‘save_post’, ‘wpse_135377_protect_post’); function wpse_135377_protect_post($post_ID) { if (in_array( ‘protected_category’, wp_get_post_categories($post_ID, array(‘fields’ => ‘slugs’)) )) { // we have to remove the function // as it will be called by `wp_update_post` (=> infinite loop) remove_filter(‘save_post’, ‘wpse_135377_protect_post’); wp_update_post(array( ‘ID’ => $post_ID, ‘post_password’ => ‘123123’, )); // now we add it again add_filter(‘save_post’, … Read more

Update post title with category name after editing a category

The solution I arrived at is using the POST value of the submitted category title, so you always get what you entered and not what was saved before. Like so: function update_group($post_id) { $updates = array( ‘ID’ => 996, ‘post_title’ => sanitize_text_field($_POST[‘name’]) ); wp_update_post($updates); } add_filter(‘edit_category’ , ‘update_group’ );