Created
August 19, 2016 11:29
-
-
Save rusty-key/f3b85d881bc0e3970eb740e358443f45 to your computer and use it in GitHub Desktop.
thtr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if($page && !empty($page) && $page!="") { | |
$offset = (int)$per_page * (int)$page; | |
$querystr = " | |
SELECT p.ID, p.post_title, m.meta_value AS date | |
FROM $wpdb->posts p INNER JOIN $wpdb->postmeta m ON p.ID = m.post_id | |
JOIN st_icl_translations tr ON p.ID = tr.element_id | |
WHERE p.post_type = 'play' AND p.post_status = 'publish' | |
AND tr.language_code = '$lang' | |
AND m.meta_key LIKE 'dates_%_date' | |
AND CAST(m.meta_value AS SIGNED) > $from | |
AND CAST(m.meta_value AS SIGNED) < $to | |
LIMIT $per_page OFFSET $offset | |
ORDER BY m.meta_value"; | |
} else { | |
$querystr = " | |
SELECT p.ID, p.post_title, m.meta_value AS date | |
FROM $wpdb->posts p INNER JOIN $wpdb->postmeta m ON p.ID = m.post_id | |
JOIN st_icl_translations tr ON p.ID = tr.element_id | |
WHERE p.post_type = 'play' AND p.post_status = 'publish' | |
AND tr.language_code = '$lang' | |
AND m.meta_key LIKE 'dates_%_date' | |
AND CAST(m.meta_value AS SIGNED) > $from | |
AND CAST(m.meta_value AS SIGNED) < $to | |
ORDER BY m.meta_value"; | |
} | |
$res = $wpdb->get_results($querystr, OBJECT); | |
$psts = array(); | |
foreach ($res as $pst) { | |
array_push($psts, array( | |
'id' => $pst->ID, | |
'title' => $pst->post_title, | |
'desc' => get_field('short', $pst->ID), | |
'date' => $pst->date, | |
'booking' => $pst, | |
'link' => get_permalink($pst->ID), | |
'ticketlink' => get_field('order_link', $pst->ID), | |
'bigbilet' => get_field('bigbilet', $pst->ID)) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment