Skip Navigation

[Gelöst] Views Filters Not working as expected on a URL

This support ticket is created vor 3 Jahre, 10 Monate. 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by stuart vor 3 Jahre, 10 Monate.

Assisted by: Luo Yang.

Author
Artikel
#1628313
viewshortcode-monday.gif
view-issue-monday.gif

I have a view that filters on a URL - e.g google.com

However, it doesn't match against the URL field unless I 're-save' the custom post manually.

Here is my workflow.

CRED form - submits the new Article post, whilst doing this it also creates a Website post (IF there is 'not' one matching the custom URL field - which is identical on both records) - This all works fine.

On the Article post, there is a View, this view looks up and matches against both custom field values and IF there is a match it creates a hyperlink to the Website custom post type.

IF on the VIEW I remove the filtering and set the Limit and Offset to more than 1, I can see that the view can find the Website CPT exists that has just been created... however, when I go to apply the filter it says it cannot be found.

IF I go into that Website post and 'Save' manually - then suddenly I can see this in the view?

Why is this behavior happening? As I have a very similar view on the Website page that matches all the Articles with the Website URL and it appears to be fine.

Attached are some images

Here is the CRED_SAVE_DATA

<?php
/**
 * Check on EDIT or New post for a website match in the 'Website' CPT - if not found add one. 
 */

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

//FUNCTION TO CHECK IF Exsists
function meta_value_exists($your_meta_value) {
    $args = array(
        'post_type'   => 'website',
        'post_status' => 'publish',
        'numberposts' => 1,
		'meta_query' => array(
                     	array('key' => 'wpcf-naked-website-domain',
                            'value' => $your_meta_value,
                            'compare' => 'REGEXP'
                            )),                   
    );
    $current_post = get_posts($args);
    if( $current_post ) {
        return true;
    } else {
        return false;
    }
}

// CRED_SAVE_DATA                    
add_action( 'cred_save_data', 'url_save_check_quickadd_website', 10, 2 );

function url_save_check_quickadd_website( $post_id, $form_data ){
  
$forms = array( 1354 );
  
if ( in_array($form_data['id'], $forms) ){ 
  
  
if (isset($_POST['quickurl'])){
		$url = strtolower($_POST['quickurl']);
 		$urlhost = parse_url($url);
		$urlhostwww = preg_replace('/^www\./', '', $urlhost['host']);
		$urldomain = preg_replace('/^(?:[-a-z0-9_]+\.)?([-a-z0-9_]+\..+)$/', '$1',$urlhost['host'])."\n"; 
//Start
		// $field_id = $_POST['quickurl'];
		$field_id = $urldomain;  
		if(meta_value_exists($field_id)){
   // do something if exists
  		//update_post_meta($post_id, 'wpcf-article-teaser', 'All ready there');
		} else {
   // do something if not exists
  		// update_post_meta($post_id, 'wpcf-article-teaser', 'added a new one');
                  $new_post = array(
					'post_title' => $urldomain,
					'post_content' => '',
					'post_status' => 'publish',
					'post_date' => date('Y-m-d H:i:s'),
					'post_author' => '',
					'post_type' => 'website',
//THE META DATA Insert
					'meta_input'   => array('wpcf-naked-website-domain' => $urldomain ),
					);
		wp_insert_post($new_post);
		}  
//Finish  
  
}
}
} 
#1628697

Hello,

It seems to be a compatibility or cache issue, please check these:
1) deactivate all other plugins, and switch to wordpress default theme 2020, and test again

2) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1630083

Not entirely sure what's going on but I think it's me...

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.