Time sort with meta_key using UNIX timestamp failing due to date differences

I will caveat this by saying that I am still not 100% sure I know what you are doing, but I believe the following will sort your results by time only assuming that your meta values are proper Unix timestamps. function orderby_time_only($orderby) { remove_action(‘posts_orderby’,’orderby_time_only’); return preg_replace(‘|(.*)\s(.*)|’,’DATE_FORMAT(FROM_UNIXTIME($1),”%k%i”) $2′,$orderby); } add_filter(‘posts_orderby’,’orderby_time_only’); $args = array( ‘post_type’ => ‘event’, … Read more

Separate [Advanced Custom Field] values by commas

Try to grab the output and echo together. <?php $post_objects = get_field(‘field’); if($post_objects!=”) : $value = array(); ?> <?php foreach( $post_objects as $post): ?> <?php setup_postdata($post); ?> <?php $values[] = ‘<a href=”‘. get_permalink() .'”>’. the_title(”,”,false) .'</a>’; ?> <?php endforeach; ?> <?php endif; ?> <?php wp_reset_postdata(); ?> <?php echo join( ‘, ‘, $values); ?>

use advance custom field inside query post command [closed]

When you do this: <?php query_posts(‘category_name=<?php the_field(‘cat_1_name’); ?>’,’showposts=5′); ?> The string argument is literally category_name=<?php the_field(‘cat_1_name’); ?>’,’showposts=5. Well, it would be if the string were not also triggering a fatal error. What you have is (assuming I haven’t lost track of the mess): String 1: ‘category_name=<?php the_field(‘cat_1_name’); ?>’,’showposts=5′ An undefined constant: cat_1_name An out of … Read more

Array sorting by custom field date

You need to use the type parameter for custom field. Try this once <?php $currentshowid = get_the_ID(); $today = date(‘Y-m-d’); $args = array( ‘meta_key’ => ‘show_id’, ‘meta_value’ => $currentshowid, ‘orderby’ => ‘meta_value_num’, ‘order’ => ASC, ‘meta_query’ =>array( ‘relation’ => ‘AND’, array( ‘key’ => ‘date_end’, ‘value’ => $today, ‘compare’ => ‘>=’, ‘type’ => ‘date’ ), ), … Read more

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