get values from specific tags in meta_value
-
PLEASE CHECK IMAGE SQL DB STRUCTURE
Hi, need some help my goal with this script is to check and retrieve the values from
<date4>(DAY),<date5>(MONTH) and <date6>(YEAR)
tags that are inside the meta_value and then compare it to the actual day and if its higher to print the ids that have higher dates than the actual date with the object to print LINKS to those pages.Up to know if managed to get this code hope someone can help me out with my goal.
$currentdate=date('Y-m-d'); global $wpdb; $sql=" SELECT post_id FROM esquel_wp_postmeta WHERE meta_value REGEXP '<date[4|5|6]>[0-9]+<\/date[4|5|6]>' "; $posts = $wpdb->get_results($sql); foreach($posts as $result) { foreach(get_post_meta($result->post_id, 'page-option-item-xml', false) as $link)//loop through 'em { $pattern = "/<date[4|5|6]>(.*?)<\/date[4|5|6]>/"; preg_match_all($pattern, $link, $matches); $dog = array(); if (!empty($matches)) { foreach ($matches[1] as $value) { $dog[]=$value; } } $dog = implode(" ", $dog); echo $dog.'<br>'; /* if ($dog>$currentdate){ echo 'True'; }else{ echo $currentdate; } */ }
- The topic ‘get values from specific tags in meta_value’ is closed to new replies.