Total Count of Posts NOT in Selected Categories?

Do your posts have multiple categories? If not – I think individual category counts are cached, so can sum up counts: $categories = get_categories( array( ‘exclude’ => $folio_cat_ids ) ); $count = 0; foreach ( $categories as $category) $count += $category->category_count; Can also just get and count the posts, that is more flexible and takes … Read more

Copy posts from one blog to another in multisite environment

To copy a post from one blog to another you can do something like this: function copy_post_to_blog($post_id, $target_blog_id) { $post = get_post($post_id, ARRAY_A); // get the original post $post[‘ID’] = ”; // empty id field, to tell wordpress that this will be a new post switch_to_blog($target_blog_id); // switch to target blog $inserted_post_id = wp_insert_post($post); // … Read more

Query posts by custom post type and custom taxonomy

Pretty sure you can’t match multiple taxonomy terms in a query–Wordpress will only honor the first one and ignore the rest. Apparently, this is scheduled to be fixed in 3.1. In the meantime, there is a plugin that’ll fix you right up: http://scribu.net/wordpress/query-multiple-taxonomies EDIT: If you want a non-plugin solution, let me know. I’ve got … Read more

Query posts by taxonomy term name

I’m not sure if the get_posts function supports the tax_query. You might want to try creating a new WP_Query object instead. $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘store’, ‘field’ => ‘name’, ‘terms’ => $mystorename ) ) ); $query = new WP_Query($args); if ( $query -> have_posts() ) : while ( $query -> … Read more

Getting movie and serial on actor page

Hy, i resolve a problem, a liitle question, how can i get the text if nothing is selected in custom field ( distributie_serial). Ex: no serial for this actor. This is the Code that works. <?php $seriale = get_posts(array(‘post_type’ => ‘serial’, ‘meta_query’ => array( array(‘key’ => ‘distributie_serial’, // name of custom field ‘value’ => ‘”‘ … Read more

Best practice for multiple queries on page

WP_Query can handle all of these cases. See the section on handling multiple taxonomies. $this_cat=”interviews”; $this_tag = ‘angelina-jolie’; $args = array( ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => $this_cat ), array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => $this_tag ) ) ); $interviews = new WP_Query( … Read more

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