Skip Navigation

[Resolved] View filter by post search with populate terms such as post title

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

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)

This topic contains 37 replies, has 2 voices.

Last updated by davidJ-4 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1821827

Minesh
Supporter

Languages: English (English )

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

I logged in to your FTP and renamed the plugins folder to plugins.disable and then I try to acess the wp-admin URL.

But when I try to access the wp-admin, I still see the following message with blank page:

Forbidden
You do not have permission to access this document.

Can you please make sure I should be able to access the admin.

#1822893

We are thinking that it is a caching issue. We reset everything and accessed it from a remote location and it is working. We are very sorry for all of this, please try it one more time.

#1824423

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

As there is no way to pass the shortcode argument to Block views, I've added the following view's filter that will allow us to pass the current post title dynamically and filter the view. I've added the following code to "Custom Code" section offered by Toolset:

add_filter( 'wpv_filter_query', 'func_custom_title_filter', 10, 3 );
function func_custom_title_filter( $query, $view_settings, $views_id ) {
    if ( $views_id == 56945 ) {
        global $WP_Views;
		global $post;
			
        if(isset($WP_Views->view_shortcode_attributes[0])){
			$query['s'] = $post->post_title;
			
			 	
		
            
        }
    }
    return $query;
}

I can see its working as expected, Can you please confirm it works at your end as well.

#1824487

Yes this is what I was expecting. I would need to create another section for another show, would I be able to use the same custom js cote with the duplicate view?

#1824515

Minesh
Supporter

Languages: English (English )

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

Yes this is what I was expecting. I would need to create another section for another show, would I be able to use the same custom js cote with the duplicate view?
==>
This is not JS code but Toolset hook which is based on php.

If you want to apply the view to multiple view IDs, you should change the following line of code:

 if ( $views_id == 56945 ) {

To:

$target_view_ids = array( 56945,9999,8888 );
if ( in_array( $view_id, $target_view_ids) ) { 

Where:
- You can replace 9999 and 8888 with your targeted view IDs.

#1828121

I added another view called "Qweens with Look at Huh" (id=57272) in the same content template.

So I changed the php code like instructed above but it is not working now.

add_filter( 'wpv_filter_query', 'func_custom_title_filter', 10, 3 );
function func_custom_title_filter( $query, $view_settings, $views_id ) {
    $target_view_ids = array( 56945,57272 );
	if ( in_array( $view_id, $target_view_ids) ) { 
        global $WP_Views;
		global $post;
			
        if(isset($WP_Views->view_shortcode_attributes[0])){
			$query['s'] = $post->post_title;
				
		
            
        }
    }
    return $query;
}
#1828125

Minesh
Supporter

Languages: English (English )

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

Can you please try the following code:

add_filter( 'wpv_filter_query', 'func_custom_title_filter', 10, 3 );
function func_custom_title_filter( $query, $view_settings, $views_id ) {
    $target_view_ids = array( 56945,57272 );
    if ( in_array( $views_id, $target_view_ids) ) { 
        global $WP_Views;
        global $post;
             
        if(isset($WP_Views->view_shortcode_attributes[0])){
            $query['s'] = $post->post_title;
                 
         
             
        }
    }
    return $query;
}

It should work. The variable name is $views_id not $view_id that I've corrected with the above code.

#1833689

My issue is resolved now. Thank you!

For future update, is it possible to add the option for filter by search with an dynamic string (such as post title, etc) to the toolset block ?