Pagination not working for Custom search form & custom result template

i’ve seen this: next_posts_link You must use wp_reset_postdata when use new WP_QUERY(), and this <div class=”pagination” id=”blog-pagination”> <span class=”previous” ><?php previous_posts_link( ‘&larr;Newer’, $loop->max_num_pages ); ?></span> <span class=”next”><?php next_posts_link( ‘Older &rarr;’, $loop->max_num_pages ); ?></span> </div> go into if($loop->have_posts()):?> condition

Display Posts by modifying the where clause only for my query

If you’re going to add the filter on the where clause, then just make sure you remove it using remove_filter() and the exact same signature immediately after you create the query. In your example, you’re using query_posts(), so add the filter, run your query, and then remove your filter right afterward. add_filter( ‘posts_where’, ‘my_posts_where_filter’, 10, … Read more

WP_Query can’t exclude more than 1 author?

You are right, it is not possible to pass an array with author IDs to exclude them. The reason is in wp-includes/query.php at line 2294 – 2298 if ( strpos($q[‘author’], ‘-‘) !== false ) { $eq = ‘!=’; $andor=”AND”; $q[‘author’] = explode(‘-‘, $q[‘author’]); $q[‘author’] = (string)absint($q[‘author’][1]); // this line select the first ID and only … Read more

How to disable main query?

This is not trivial, because “home,category and search” are logically determined while main query churns through stuff. I am pretty sure I read this is possible, but that was in context of syndicating site that hadn’t used posts/loop at all and scrapped it to do different stuff. More typical approaches are: Integrate custom logic into … Read more

How to query for a week using key => value WP_Query argument notation?

There isn’t a week query variable, but there is w: http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters w (int) – Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the “start_of_week” option. Your args should look like this: $args = array(‘category_name’ => ‘whats-happening’, ‘year’ => 2012, ‘w’ => 46 ,’paged’ => $paged);

WP_Query sort by comment meta data

I solved my problem by adding a hook on the action wp_insert_comment. When my hook is called i calculate the average rating for each rating meta-tag of my comments. Then i add a meta tag to the post with the result I can use the post meta-tag to sort with wp-query

WP_Query based on URL parameters

Try like this $meta_query = array(‘relation’ => ‘AND’); if($queryGenre) { $query_genre = array( ‘key’ => ‘genre’, ‘value’ => $queryGenre, ‘compare’ => ‘=’, ) ; array_push($meta_query,$query_genre); } if($queryMood) { $query_mood = array( ‘key’ => ‘mood’, ‘value’ => $queryMood, ‘compare’ => ‘=’, ) ; array_push($meta_query,$query_mood); } and at the end do array_push($args,$meta_query);

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