Hi there, I have a problem with the Dokumentation Querying the database for repeater sub field values.
When I use the code
$rows = $wpdb->get_results($wpdb->prepare(
"
SELECT *
FROM wp_postmeta
WHERE meta_key LIKE %s
AND meta_value = %s
",
'images_%_type', // meta_name: $ParentName_$RowNumber_$ChildName
'type_3' // meta_value: 'type_3' for example
));
then i get also posts they are not published (e.g. revisions).
Any ideas how can I modify the query that get only published posts?
Hi @davelee
Within the loop of $rows, you could find out the status of the post like so:
<?php
// loop through the results
if( $rows )
{
foreach( $rows as $row )
{
if( get_post_status($row->post_id) != 'publish' )
{
continue;
}
// run code here
}
}
?>
Hope that helps.
Thanks
E