Create single.php for specific category by category id

You can use this function to add category specific single template pages on your website. This goes in functions.php You can define as many single templates as you want. function wpse_category_single_template( $single_template ) { global $post; $all_cats = get_the_category(); if ( $all_cats[0]->cat_ID == ‘1’ ) { if ( file_exists(get_template_directory() . “/single-cat1.php”) ) return get_template_directory() . … Read more

Posts from multiblt categories but featured image only in the first one, the rest to have the post title only

General notes 1st of all: You don’t have to use the (imho crappy) TimThumb thingy. There’re much better things like my (freely available, open source) »Dynamic image resize« plugin. 2nd (and afaik), you can do this with on board stuff, like get_image_tag() in your case. 3rd: Don’t throw that many variables into the global namespace. … Read more

Can the_category display a post count?

How about this… add_filter(‘get_the_categories’, ‘wpse50876_the_counter’); function wpse50876_the_counter($cats){ foreach($cats as $cat){ $cat->cat_name = $cat->cat_name.'(‘.$cat->count.’)’; } return $cats; } Try it…

Add specific word before the category page title

Since WP 4.4 you can change document title using document_title_parts filter hook, in earlier versions it will be wp_title_parts (since v4.0) or wp_title filter. add_filter( ‘document_title_parts’, ‘se333744_site_title’ ); function se333744_site_title( $title ) { if ( isset($title[‘title’]) && strlen($title[‘title’]) && !is_front_page() && is_archive() ) $title[‘title’] = ‘ {some prefix} ‘ . $title[‘title’]; return $title; }

Prevent function from triggering again when post in specific category gets another category?

We can utilize the add_term_relationship action to check if the current post is already assigned as popular. add_term_relationship fires before a term is inserted. I also think that you are using the wrong hook here to send your mail on. added_term_relationship fires quite early before any error checking. You can still encounter a failure after … Read more

How we add new categories by wp_insert_post

$id = wp_create_category(‘My category name’); By above function category created & categary id is returned. If the category already exists, it is not duplicated. The ID of the original existing category is returned without error. You can use $id as category id. Reference http://codex.wordpress.org/Function_Reference/wp_create_category