Set default (auto) slug prefix for Tags

You can use the created_term or the created_{taxonomy} hooks which are fired just after a taxonomy term is created (the second only if it matches the taxonomy). The following will only alter terms in the taxonomy ‘my-taxonomy’. (I believe for the default tags, taxonomy should be ‘post_tag’). add_action(‘created_term’, ‘my_add_prefix_to_term’, 10, 3); function my_add_prefix_to_term( $term_id,$tt_id,$taxonomy ) … Read more

Counting number of posts in a category and its sub categories and displaying result using shortcode

The shortcode // Add Shortcode to show posts count inside a category function category_post_count( $atts ) { $atts = shortcode_atts( array( ‘category’ => null ), $atts ); // get the category by slug. $term = get_term_by( ‘slug’, $atts[‘category’], ‘category’); return ( isset( $term->count ) ) ? $term->count : 0; } add_shortcode( ‘category_post_count’, ‘category_post_count’ ); Usage … Read more

Get current term’s ID

Here is a function I use to list subterms: /** * Lists all subentries of a taxonomy. * * @return void */ function ttt_get_subterms( $args = array () ) { if ( ! isset ( get_queried_object()->taxonomy ) ) { return; } $options = array ( ‘child_of’ => get_queried_object_id() , ‘echo’ => 0 , ‘taxonomy’ => … Read more

Sort posts by number of matched terms

Well the only way i can think of is to create an two dimentions array of the results you want to output, and the number of matching tags. so for example: $results = array(); $searched_tags = $_post[‘my_tax’]; $searched_tags = explode(“+”, $searched_tags); while (have_posts()){ $the_post(); $result[‘r’] = ‘<div class=”post”> <div class=”title”><h2><a href=”‘.get_permalink($post->ID).'” title=”‘.get_the_title($post->ID).'”>’.get_the_title($post->ID).'</a></h2></div> <div class=”excerpt”>’.get_the_excerpt().'</div> </div>’; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)