WordPress loop based on url sting

use $_GET[‘Price’] and $_GET[‘Region’] to get the price and region values from the url and add them to your query args. It is rather hard without any code to start from, but try something like $queryPrice = (strpos($_GET[‘Price’],’-‘) ? explode(‘-‘, $_GET[‘Price’]) : array($_GET[‘Price’], $_GET[‘Price’])); $queryRegion = $_GET[‘Region’]; $args = array( // all your args here … Read more

How to append short url to specific external links

Mostly from https://stackoverflow.com/questions/7118823/check-if-url-has-certain-string-with-php Check if the url has your string, then spit something different out based on it. Perhaps something like… $url=”http://” . $_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’]; if (false !== strpos($url,’forms.woo.com’)) { echo ‘?pageurl=” . home_url() . get_the_ID(); // there”s your page id url } else { the_permalink(); // plain old permalink }

Query String for the WP_QUERY parameters

PHP function http_build_query(); would return different string for this array. It won’t remain readable like an array but, I believe, it will work as parameter to WP_Query. build_query is the WordPress equivalent for the same functionality. Turns out that build_query is a bit different from http_build_query. http_build_query returned date_query%5B0%5D%5Bafter%5D=24+hours+ago and build_query returned date_query%5B0%5D%5Bafter%5D=24 hours ago. … Read more

adding tax_query to $query_string

the best way of doing this is WP_Query $query = new WP_Query( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘my_custom_tag’, ‘slug’ => ‘slug’, ‘terms’ => array( ‘my_tag_slug’ ), ‘operator’ => ‘in’, ), ) ); and you should do the ajax callback like this add_action( ‘wp_ajax_my_action’, ‘my_action’ ); function my_action(){ //my custom code … … Read more

Query string order by custom field

The query_posts is only useful when you actually know what you are doing. Base on the info you provide this should work for you : $the_query = new WP_Query(array( ‘post_type’ => ‘your_cpt’, ‘posts_per_page’ => -1,//get them all ‘meta_key’ => ‘field_4’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’ )); ?> <?php if( $the_query->have_posts() ): ?> <ul> <?php … Read more