Hard coded main navigation

STYLING With a static navigation, the CSS you mentioned, won’t work. Use the simple HTML parameters: #access a:link, #access a:active, #access a:visited{ font-weight: bold; } CODING In my project, I used echo get_the_category_by_ID( 11 ); to echo the Category name of the cat_ID = 11. You can show the cat name by this. For page … Read more

Checking for two categories in query_posts

Don’t use query_posts. Use WP_Query, and use it’s tax_query. $query = new WP_Query( array( … ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘recent-work’, ‘plumbing’, ‘cat3’ ) ) ), ‘posts_per_page’ => 1 … );

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