another point is to to add Post status into search filed so that once can search post based on Post Status.
Hello and thank you for contacting the Toolset support.
There is no built-in filter for the post status in the view's filters. You need to add it manually and alter the query filters programmatically with custom code. Check this reply from my colleague Luo on another ticket https://toolset.com/forums/topic/post-status-filter-select/#post-306570
I hope this helps. Let me know if you have any questions.
My issue is resolved now. Thank you!
What I couldn't understand it is
Yes, it is possible with Views filter hook "wpv_filter_query", for example,
1) edit your view, in section "Filter", add a dropdown menu for post status, like this:
where I can found the section "Filter" as still unable to find that . Can you help me.
Still waiting for your kind response.
Hello and my apologies for the late reply, but I do not work on Wednesdays and Thursdays.
If you are building the view with the legacy editor, make sure that the search is activated in the screen options. Check this screenshot hidden link
Then add the dropdown, using HTML, as there is no built-in filter for post types, in the Search and Pagination section. My apologies for the confusion. hidden link
If you are building the view with Blocks, make sure to activate the search for the view and use an HTML block to build the dropdown. Check this screenshot hidden link
Thank, I have created it but still unable to filter Post based on Post Staus. Can you help me out furhter.
Maybe you did not add the custom code to modify the view's query arguments!
Of course, I'll do my best to help. Let me access your site's backend and check what has been done so far. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
The view is built using blocks and it presents an issue with the view's shortcode. I replaced the shortcode with HTML code and it displays all the statuses. hidden link
<select id="wpv_control_select_my-post-status" name="my-post-status[]" style="" class="js-wpv-filter-trigger wpcf-form-select form-select select">
<option value="any" class="js-wpv-filter-trigger wpcf-form-option form-option option">Any</option>
<option value="publish" class="js-wpv-filter-trigger wpcf-form-option form-option option">Publish</option>
<option value="pending" class="js-wpv-filter-trigger wpcf-form-option form-option option">Pending</option>
<option value="draft" class="js-wpv-filter-trigger wpcf-form-option form-option option">Draft</option>
<option value="trash" class="js-wpv-filter-trigger wpcf-form-option form-option option">Trash</option>
<option value="future" class="js-wpv-filter-trigger wpcf-form-option form-option option">Future</option>
</select>
However, the search is performed using AJAX, which means that performs POST requests instead of GET request. Check this hidden link
The code needs to be adapted to check for POST parameters instead of GET parameters. If you would allow me a copy of your website I'll debug the code locally and get it to you. Sounds good?
ok do proceed would request only for sellit ..
and just to let know that next step is to creat front end editing with the option to change post status so there I need your guidence as well
The custom code checks against a wrong ID, 492 is the ID of the page. The ID of the view is 493. Change the code to the following and it will work:
add_filter( 'wpv_filter_query', 'my_posts_by_status', 10, 3 );
function my_posts_by_status ( $query_args, $view_settings, $view_id ) {
if( $view_id == 493 ) {
if(isset($_GET['my-post-status'])){
$query_args['post_status'] = $_GET['my-post-status'];
} else {
$query_args['post_status'] = array('any');
}
}
return $query_args;
}
I tried this on my local install because I needed Duplicator Pro to copy a subsite in a multisite Install.
Let's work on the other request on a new ticket.
Hi Jamal,
It is working now but due to some reason as I open up the page I received following page as popup, it i strange to me why?
But only for login user and I am using firefox.
Previusly it was not like that..
I have updated the code as below:
in case need new more forms.
add_filter( 'wpv_filter_query', 'filter_post_type_status_func', 10, 3 );
function filter_post_type_status_func( $query_args, $view_settings, $view_id ) {
if ( in_array($view_id, array(493)) ) {
if(isset($_GET['my-post-status'])){
$query_args['post_status'] = $_GET['my-post-status'];
}
}
return $query_args;
}
That's the View's debug popup. I must have left it activated in Toolset->Settings->Front-end Content(tab). Read more about it here https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#the-views-debug-tool
Ah ok good to know I guess that is just for backend debug but once again great tool.
Now I have created a Front end Form for editing as well only thing is to make changes to post satus via Post Editing front end from would be great if you can see it today and help me out further as well. Then I don't have to explain it to any one else.