Add multiple value to a query variable in WordPress

I am giving you some solutions whatever you want to use. Using plus http://myexamplesite.com/store/?brand=nike+adidas+woodland //Don’t decode URL <?php $brand = get_query_var(‘brand’); $brand = explode(‘+’,$brand); print_r($brand); ?> using ,separator http://myexamplesite.com/store/?brand=nike,adidas,woodland $brand = get_query_var(‘brand’); $brand = explode(‘,’,$brand); print_r($brand); Serialize way <?php $array = array(‘nike’,’adidas’,’woodland’);?> http://myexamplesite.com/store/?brand=<?php echo serialize($array)?> to get url data $array= unserialize($_GET[‘var’]); or $array= unserialize(get_query_var(‘brand’)); print_r($array); … Read more

How to display Section for certain time

Check the time parameter on WP_Query Class. There is a example on how to show posts form last 30 days. You can do it for last couple of hours, minutes or even seconds! Code is tested and working. $args = array( ‘posts_per_page’ => 1, // We are showing only one post ‘category_name’ => ‘prime’ // … Read more

wordpress query – orderby child post date

You should be able to do this with the get_children function (see the codex), $ticket_id = 34; // assume you want to retried the replies of ticket post id=34 $args = array( ‘post_type’ => ‘support_tickets’, ‘numberposts’ => -1, ‘post_parent’ => $ticket_id, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ); $replies = get_children( $args ); Assuming that … Read more

Is there any difference between hooks posts_where with posts_join and posts_search performance wise?

All of these hooks are called in a similar fashion and get passes similar data. Under normal circumstances there should be no meaningful performance difference between them. One scenario I can think of is that if you aren’t properly targeting your code to specific queries and it runs in every query then posts_search might fire … Read more

How to List Events by Year and Month Using Advanced Custom Fields?

This should get you started: <?php $the_query = new WP_Query( array( ‘post_type’ => ‘kalender_item’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘kalender_item_datum’, ‘orderby’ => ‘meta_value’ ) ); # This will hold what group we’re in $current_header=””; # The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); # get the datum for this post $temp_date = get_post_meta( get_the_ID(), ‘kalender_item_datum’, … Read more

wpdb get posts by taxonomy SQL

Sorry guys, I just found the solution: SELECT p.post_name, t.name as clientName FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON (‘p.ID’ = tr.object_id) INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) INNER JOIN $wpdb->terms AS t ON (t.term_id = tt.term_id) WHERE p.post_status=”publish” AND p.post_type=”portfolio” AND tt.taxonomy = ‘clients’ ORDER BY p.post_date DESC … Read more

Create pagination and order according to alphabet

i wrote about something similar recently, maybe it could be helpful to you: http://www.kathyisawesome.com/424/alphabetical-posts-glossary/ it was based off of my answer to this question: Group Posts by First Letter of Title the answer includes both my original posts_where solution and an alphabetical “menu” that for some reason i didn’t write about in my tutorial