[Resolved] Do not display latest post with custom field value
This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I have created a CPT. In the post fields is a radio selection with two options; "yes" and "no".
In the view created for the CPT, i want to show all posts except the latest post with "yes" selected in that field (I am showing that elsewhere on the page).
How can I do this? Is there a conditional statement or filter that I can use?
i want to show all posts except the latest post with "yes" selected in that field (I am showing that elsewhere on the page).
==> I need more explanation with the above line, may be a test case example will be enough to understand your exact requirement.
You should use view's filter hook: wpv_filter_query
Using this hook you can fetch the specific post id which is latest and custom field value set 'YES' and then use 'post__not_in' argument with your query.
Add following code to your current theme's functions.php file and change following code as per guidelines:
add_filter('wpv_filter_query', 'featured_products_random_order', 10, 2);
function featured_products_random_order($query, $settings) {
if ($settings['view_id'] == 9999) {
global $wpdb;
$id = WRITE QUERY TO GET POST ID of latest post with custom field set with value = yes
$query['post__not_in'] = $id;
}
return $query;
}