Filter Posts by current Month

$current_month = date(‘m’); should be $current_month = date(‘n’); Reference the page for the WP_Query object: codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters “month_num” is an int from “1-12”, not from “01-12”. The way the variables are currently set up, $current_month has a preceding zero. I’m assuming that a simple change to return the month without a preceding zero will fix this. … Read more

How can I get a list of comments by target

When it comes to retrieve posts, it’s supposed to call WP_Query. WP_Query has an argument called meta_query but it doesn’t have comment_query. So it might need a trick to achieve what you want, $args = array(); $args[‘feed’] = 1; $args[‘withcomments’] = 1; $args[‘author’] = 1; //author id. $query = new WP_Query($args); $posts = $query->posts; //do … Read more

example of build_query function?

build_query() converts an array into a string to be used in an URL. You can pass an array or an object: $test1 = array ( ‘foo’ => ‘bar’, ‘hello’ => ‘world’ ); $query1 = build_query( $test1 ); print “<pre>$query1</pre>”; // foo=bar&hello=world $test2 = array ( ‘foo’ => ‘bar’, ‘hello’ => ‘world’, ‘one’ => array( 1, … Read more

How to reduce the number of queries?

Try this: global $wpdb; $num_cat = 6; $query = “SELECT tt.term_taxonomy_id, t.name, COUNT( t.name ), GROUP_CONCAT( p.ID ) , GROUP_CONCAT(m.meta_value) FROM {$wpdb->prefix}term_taxonomy tt NATURAL JOIN {$wpdb->prefix}terms t NATURAL JOIN {$wpdb->prefix}term_relationships tr JOIN {$wpdb->prefix}posts p ON ( tr.object_id = ID ) JOIN {$wpdb->prefix}postmeta m ON ( post_id = ID ) WHERE taxonomy = ‘category’ AND post_type=”post” … Read more

What’s wrong with my $wpdb prepare?

These look like 2 separate questions. The first I think is a single vs double quotes issue: Try this: $html=””; foreach ( $recent_across_network as $post ) { $html .= ‘blog_id, ‘.$post->ID.’ ) . ‘”>’ . $post->post_title . ”; } $html .= ”; The line in the foreach is putting $post->ID in single quotes which won’t … Read more

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