Query all posts and not repeat the same tag

You can try something like this: <?php $tags_array = get_tags(); $news_query = new WP_Query; foreach ( $tags_array as $tags ) : $news_query->query( array( ‘cat’ => $tags->term_id, ‘posts_per_page’ => 1, ‘no_found_rows’ => true, ‘ignore_sticky_posts’ => true, )); ?> <h2><?php echo esc_html( $tags->name ) ?></h2> <?php while ( $news_query->have_posts() ) : $news_query->the_post() ?> <div class=”post”> <?php the_title() … Read more

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

The difference is what is returned. The WPDB query() method returns true for CREATE, ALTER, TRUNCATE and DROP queries, an integer of how many results for all other queries, or simply false if if there’s an error. The WPDB get_results() method actually returns the entire result of the query (like you would get running the … Read more

Listing posts by grouping dates

I’ve been using the following plugin for Event management, and it has short code to display all events and sort them by date. It also has some developer features to give you a bit more control over things. http://wordpress.org/extend/plugins/events-manager/ Very cool plugin that is actively developed.

WordPress query by category, sorted by custom field

I don’t think there’s an easy to sort by three different meta values, and really, I don’t see why you need to in this case. Why not just save the event date in one meta value and sort by that? It makes your query much more efficient (removes two unnecessary joins) and lets you use … Read more

Help with wordpress custom query and advanced custom fields plugin

$yesterday = array ( ‘year’ => date(‘y’), ‘month’ => date(‘m’), ‘day’ => date(‘d’)-1 ); $rows = $wpdb->query($wpdb->prepare(*emphasized text* “SELECT id, yymmdd FROM plugin_data WHERE yymmdd LIKE ‘%d-%d-%d”, $yesterday[‘year’], $yesterday[‘month’], $yesterday[‘day’] )); foreach ( $rows as $r ) { $id_for_yesterday_rows[]= $r->id; } Now you have all ids or rows that were submitted yesterday in an array.