Skip Navigation

[Resolved] Custom post disappears from the list after saving

This thread is resolved. Here is a description of the problem and solution.

Problem:
Custom post disappears from the list after saving

Solution:

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/custom-post-disappears-from-the-list-after-saving/#post-1342115

Relevant Documentation:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

This support ticket is created 5 years, 2 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.

Our next available supporter will start replying to tickets in about 1.16 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by katjaL 5 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1342009

For some reason the CP's don't show in the list anymore after saving.

Before saving they are there -> I open a post, just save it (I don't even change anything) -> the post disappears from the list.

Now also another thing while creating this ticket, the toolset debug information is completely empty, so I can't provide it.

#1342043
#1342045

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you be more specific - with what post type you have issue with or what post type I should check and what steps I should follow to see the issue. Maybe the problem URL will help.

#1342049
#1342061

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please check the field "Ensi-ilta" - the date field is empty:
=> hidden link

Now, I see you added the filter to your view:
=> hidden link

Select items with field:
Vuosi is a string equal to URL_PARAM(wpv-wpcf-vuosi)
AND
Ensi-ilta is a number lower than TODAY()

Where - you set - Ensi-ilta is a number lower than TODAY()

so, it seems as the field is empty, it removes the entry, you should try to set the date of tomorrow to the field Ensi-ilta and save it and then check on front-end.

#1342071

Ah ok... This is a bit complicated setup for me to get working. The Ensi-ilta is a date field that is used sometimes, but not always, so it can be also empty. Is it possible to have it like

Vuosi is a string equal to URL_PARAM(wpv-wpcf-vuosi)
AND
Ensi-ilta is a number lower than TODAY() OR empty

#1342115

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I think it can be achieved using the view's hook: wpv_filter_query
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

I've added the following code to "Custom Code" section offered by Toolset:
hidden link

add_filter( 'wpv_filter_query', 'func_custom_filed_filter_ilta',99,3);
function func_custom_filed_filter_ilta($query_args, $view_settings, $view_id) {
   
    if($view_id==24736){
    
        $meta = $query_args['meta_query'];
        foreach($meta as $k=>$v):
            if($v['key'] == 'wpcf-ensi-ilta'){
              
         
           $filter_array =   array(
						'relation' => 'OR',  
						$v,
						array(
						'key' => 'wpcf-ensi-ilta',
						'compare' => 'NOT EXISTS',
						),
             			array(
						'key' => 'wpcf-ensi-ilta',
                                                'value'=>'',
						'compare' => '=',
						)
             
				);
              
           		 $query_args['meta_query'][$k] = $filter_array;
                
                    
            }
        endforeach;
       }
  return $query_args;
}

Can you please confirm now you able to see the expected results:
=> hidden link

#1342307

My issue is resolved now. Thank you thousands Minesh!