Filtering posts by multiple taxonomies

First off, you should be using WP_Query vs query_posts. Have a look at the Taxonomy Parameters. Mainly tax_query and relation. // Repost from link above $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, … Read more

category__not_in — anyway to use category name instead of id?

You can use List Category Posts (Disclaimer: I’m the author of List Category Posts) or you can code this yourself: $category_id = get_cat_ID($category_name); This way you can get the id and exclude it from the loop with the minus sign. Example: get_posts(cat=-1);

Exclude filter on front page

You can just remove the filter before calling the_excerpt and then add it back afterwards… remove_filter(‘excerpt_more’,’new_excerpt_more’); the_excerpt(); add_filter(‘excerpt_more’, ‘new_excerpt_more’);

If No Search Results, Show Posts from Alternate Search Query

I’ve never seen it done before but the logic of the PHP IF/ELSE should mean you could simply plug a new query in after the ELSE: if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part ( ‘templates/post’, ‘main’ ); endwhile; else: $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : … Read more

get_the_foo() in the loop – does it perform another query?

Query results for posts, terms, and metadata get placed in cache. If a function is called that accesses data from previously queried objects within the same request (or you’re using a persistent cache mechanism that maintains data across requests), it will not trigger another query and will instead fetch the data from cache.

Ajax loop in sidebar to load post titles/categories

What is the script for you posted here? I hope it is not the script that will be called by the ajax request, isn’t it?? Normally a php script for an ajax request looks like this: <?php $output = array(); $posts = new WP_Query( array( ‘showposts’ => 20 ) ); foreach ( $posts as $post … Read more

Getting page ID inside loop

You can use all template tags inside this file, so to get the ID, just use get_the_ID() (or the_ID() to output it). get_the_ID() will retrieve the numeric ID of the current post. It has no parameters and returns the ID of the current post. the_ID() will display the numeric ID of the current post. It … Read more

Sort Popular Posts by Views for the Last Week

Use strtotime to compare dates. $start = strtotime(‘yesterday’); $end = strtotime( ‘+1 week’,$start); $args = array( ‘posts_per_page’ => 5, ‘ignore_sticky_posts’ => 1, ‘meta_key’ => ‘sw_post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘date_query’ => array( ‘after’ => $end, ‘before’ => $start, ), ); $popularpost = new WP_Query( $args ); if ( $popularpost->have_posts() ) { while ( … Read more

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