Hi,
I’m using the sf_input_object_pre
hook to edit the post type select field in the search form – which works great! I’ve used it to combine post types, for example, people who use my site don’t know the difference between posts and pages, they know them all as “Articles” – so I re-labeled “Posts” as “Articles” and changed the value where the post types get passed as “post,page”. And then I unset the Page option so there wouldn’t be duplication.
This works fine, however, since I’m combining post types, the “selected” value that shows once the form is submitted does not show. So “Articles” won’t stay selected after the results are filtered, I guess because the select field is probably just checking one post type against one post type where I’m now passing two. Is it possible to achieve this with the filter hook I’m using? Here is what my function looks like:
function customize_post_type_filter( $input_object, $sfid ) {
if ( $input_object['name'] == '_sf_post_type' ) {
//update this field before rendering
if ( isset( $input_object['options'] ) ) {
foreach ( $input_object['options'] as $option ) {
//combine posts and pages option
if ( $option->label === 'Posts' ) {
$option->label = 'Articles';
$option->value = 'post,page';
}
}
unset( $input_object['options'][2] );
}
}
return $input_object;
}
Thanks!