list tags with count in author profile page

Here you go: function get_author_post_tags_wpa78489($author_id,$taxonomy = ‘post_tag’){ //get author’s posts $posts = get_posts(array( ‘author’ => $author_id, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’ ) ); $ts = array(); //loop over the post and count the tags foreach ((array)$posts as $p_id) { $tags = wp_get_post_terms( $p_id, $taxonomy); foreach ((array)$tags as $tag) { if (isset($tags[$tag->term_id])){ //if its already … Read more

WP_Query Variable inside Array

Your array definitions aren’t correct. This… elseif($_REQUEST[“price”] == 20){$price = “array( ’19’, ’20’ )”;} … creates a literal string that reads “array( ’19’, ’20’ )”. Remove the quotes. elseif($_REQUEST[“price”] == 20){$price = array( ’19’, ’20’ );} That should give you PHP arrays.

WP_Query posts by distance based on LAT & LNG in Database

You want to use the Haversine formula http://en.wikipedia.org/wiki/Haversine_formula This plugin might be of interest to you: http://wordpress.org/extend/plugins/wp-geoposts/ Provides WP_GeoQuery an extended WP_Query class for doing distance based and geo-aware queries. it uses the Haversine formula here: http://plugins.svn.wordpress.org/wp-geoposts/trunk/query.php

How to display 7 most recent days of posts?

You can do all of this outside the template, via the pre_get_posts action and a filter on posts_where. The first function checks if it’s the main query and the home page, if so it applies a filter to the query’s posts_where clause. The posts_where function limits post selection to today’s date minus 7 days, then … Read more

Make WP_Query more efficient?

you can try some of these extra parameters: ‘update_post_term_cache’ => false, ‘update_post_meta_cache’ => false, ‘cache_results’=>false, ‘no_found_rows’ => true, ‘posts_per_page’=>1, ‘post_status’=’publish’, ps: you can measure the speed of your query when you are testing it with microtime() http://php.net/manual/en/function.microtime.php Edit: Here is a another way: function count_votes($user_id=1, $question_id=1, $post_type=”vote”, $meta_key=’comp_question’){ global $wpdb; $sql = “SELECT count(*) FROM … Read more

Setting get_queried_object

As per its laconic source: function get_queried_object() { global $wp_query; return $wp_query->get_queried_object(); } This function retrieves object from main query. As such it is affected by anything that changes main query. From your list that would be query_posts() (reason number umpteen it should not be used).

How to query a custom post type with a taxonomy filter but display post type archive page?

The simplest way is, in all honesty, to hook into wp_title and change things, and just be aware that the warnings are there but not showing in production (because you’ve property configured your server). What follows is a kind of hacky solution. If you take a look at get_queried_object… <?php function get_queried_object() { global $wp_query; … Read more