Views plugin lets you build your own custom search for any content type. These searches can be based on post content, taxonomies and custom fields.
When you ask for help or report issues, make sure to tell us settings for your custom search.
Viewing 15 topics - 526 through 540 (of 746 total)
Problem: I would like to create a parametric search View that allows users to filter a list of posts by post status, using a dropdown select filter.
Solution: It is not currently possible to create front-end filters for post status. Other workarounds proposed in the past have limitations that are not easily overcome with custom code. Instead, the most practical approach is to create a custom select field that includes values corresponding to each possible post status. Copy the actual post status information into the value of this custom field for each post, and set up a parametric search View that filters upon this custom field.
In this case the posts are created in Forms, and a generic select field is used to allow the User to choose a post status for the created post. There is a custom code snippet using the cred_submit_complete API to programmatically set the post status after the Form is submitted. We can tap into that event hook to also set the custom field value programmatically with update_post_meta:
add_action('cred_submit_complete', 'my_save_draft',10,2);
function my_save_draft($post_id, $form_data)
{
// if a specific form
if ($form_data['id'] = array(737,521))
{
if (isset($_POST['post_stat']))
{
// update post status
$my_post = array(
'ID' => $post_id,
'post_status' => $_POST['post_stat'],
);
wp_update_post($my_post);
// add / update post-status custom field value
update_post_meta( $post_id, 'wpcf-post-status', $_POST['post_stat']);
}
}
}
Problem: I have a custom search View with post relationship filters for City and State, but some Cities never appear in the filters.
Solution: Be sure to provide default options for all search filters like number of bedrooms and number of bathrooms, otherwise, Cities without matching Properties will never appear in the filter options.