Get all comments of author’s posts

It looks like there’s two problem with the code you’re trying to use. The first is AUTHOR_ID. Unless you have this defined somewhere else, then this is going to cause an undefined constant error. The second one is that there should be a closing PHP tag ?> before <?php endwhile; ?>. Another thing is, that … Read more

Add content in between of foreach

You can keep tracks of number of cycles and run extras when counter matches. Something like this: $array = array(1,2,3,4,5); $i = 0; foreach($array as $set) { if(2 == $i) echo ‘after 2’; if(4 == $i) echo ‘after 4’; echo $set; $i++; } I must note that this is more of PHP basics and really … Read more

How to get events using multiple custom meta fields?

You can use your current code to create the query and then in your loop run a check before displaying the events something like <?php query_posts(‘meta_key’ => ‘end_date_value’, ‘meta_compare’ => ‘>’, ‘meta_value’ => $todaysDate); while ( have_posts() ) : the_post(); $post_custom = get_post_custom($post_id); if ($startDate < $post_custom[‘start_date_value’]){ //your loop here } } ?> keep in … Read more

Custom query for custom post_type

change your query a bit: $todays_date = time(); $args = array (‘post_type’ => ‘tasks’, ‘meta_key’ => ”end_date, ‘meta_compare’ => ‘<‘, ‘meta_value’ => $todays_date, ‘orderby’ => ‘meta_value’ ); $tasks = get_posts($args); and then for each one of this posts get the start_date meta and compare with $today something like: $today = strtotime($today); foreach ($tasks as $task_post){ … Read more

Query of custom post types only shows first post

I think you need to change: $case_studies->query(‘post_type=case_studies&p=54,49,44’); to $case_studies->query_posts( array( ‘post__in’ => array( 54, 49, 44 ) ) ); I’d look at this page for LOTS more examples. http://codex.wordpress.org/Function_Reference/query_posts. when your there search for “Multiple Posts/Pages Handling”. Hope this helps, I’m still new to wordpress.

And/Or Category Query

Strange, that usage of category__and should be working. As for following logic I don’t think you can accomplish anything that complex with query parameters. There are several possible ways to deal with it that I can think of: simplify category structure and/or selection logic; modify raw SQL with posts_where filter; store selection criteria in post … Read more

Use mysql_query instead of $wpdb query

Simple and short: mysql_query() = Faster! $wpdb->get_results() = Safer! But in most cases since $wpdb is a global object and already in the memory using it will be be as fast as mysql_query(). Will this affect my performance? It can affect for better performance changes but they would be minor changes that its just not … Read more

querying a custom field

i am not sure that this is place you should change the shortcode This code retrieves several values and not one.. as i understand it you are looking to get one value back right ? that’s much simpler and doesen’t require the use of “foreach” you simply put this in the desired location <?php echo … Read more