Query multiple taxonomy in Custom Post Type

There’s the “tax_query” argument available since the latest wp release: global $query_string; $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘status’ ,’terms’ => array( ‘available’, ‘pending’ ) // change to “sold” for 2nd query ,’field’ => ‘slug’ ), ); $args[‘post_type’] = ‘listing’; parse_str( $query_string, $args ); $avail_n_pend = query_posts( $args ); if ( $avail_n_pend->have_posts() ) : while … Read more

get_terms return errors

As i was mentioning before, it’s a case of your term fetching occuring before the taxonomy has been registered. The init action occurs after the theme’s functions file has been included, so if you’re looking for terms directly in the functions file, you’re doing so before they’ve actually been registered. Here’s a portion of the … Read more

Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url

WordPress parses incoming URLs with a list of regular expressions, the rewrite rules. The first regex that matches the URL “wins”, and determines what kind of query will be executed. You can see the rewrite rules and play with different URLs with my Rewrite analyzer plugin. Whether or not pages take priority over other rules … Read more

How to add automatically keyword to taxonomies when a post published, and assign them to the post

You would use the save_post hook, in your hooked function use wp_insert_term as described here: http://codex.wordpress.org/Function_Reference/wp_insert_term Then use wp_set_object_terms on the post to assignt he taxonomy term you just created as follows: http://codex.wordpress.org/Function_Reference/wp_set_object_terms for example: function my_save($post_id) { wp_insert_term( ‘bannanapost’, ‘fruit’); wp_set_object_terms( $post_id, ‘bannanapost’, ‘fruit’, true ) } add_action(‘save_post’,’my_save’); The above code, placed in functions.php … Read more

Custom Post Type with Custom Title

You can try the following code. function custom_post_type_title ( $post_id ) { global $wpdb; if ( get_post_type( $post_id ) == ‘cars’ ) { $engine=”, “.get_post_meta($post_id, ‘Engine’, true).’l’; $terms = wp_get_object_terms($post_id, ‘brand’); $abrand= ‘ ‘.$terms[0]->name; $amodel=” “.$terms[1]->name; $title = $post_id.$abrand.$amodel.$engine; $where = array( ‘ID’ => $post_id ); $wpdb->update( $wpdb->posts, array( ‘post_title’ => $title ), $where ); … Read more

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