Skip Navigation

[Resolved] Home default search results

This support ticket is created 6 years, 9 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 7 replies, has 2 voices.

Last updated by Minesh 6 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#617672

Hi,

I have a question regarding this site:

hidden link

On the home page, before any search is made using the filters on the left-hand side, all of the existing posts appear on the table. Since I intend to create hundreds of entries, I would like to limit the number of entries that appear on the table when the user enters the site.

Could it be possible to insert a custom field for featured posts and then, on the home page, only show those featured posts?

Thanks in advance for your help!

Daniel

#617828

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - if you do not want to display all results you can add pagination to your view.

More info:
=> https://toolset.com/documentation/user-guides/views-pagination/

And if you want to make few post featured as you described in your initial query, you can do that as well, you should create a custom field that will hold the status that post is featured or not, maybe checkbox field and later add custom field filter for this checkbox field to display the records.

More info:
=> https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/

#618035
query filter not found.png

I don't see the query filter option.

I am in the View Edit page. See screenshot attached.

I am not sure if you understand what I mean: I want that when the user enters the home page, only the featured posts appear by default, but when user changes the search options and clicks on the Search button to find the posts he wishes, the result should match the filters selected.

So filter for the featured posts should only be temporary until the user makes a search.

I hope I made myself clear.

Thanks

#618195

Minesh
Supporter

Languages: English (English )

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

Yes - its possible but I need information that which field need to be use to check if post is featured post or not?

#618252

OK. The field is "Destacada" and it is checkbox field.
thanks

#618257

Minesh
Supporter

Languages: English (English )

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

Well - I tried to add following code to your current theme's functions.php file but it says there is no write permission granted.

add_filter( 'wpv_filter_query', 'func_show_only_featured_posts', 10, 3 );
function func_show_only_featured_posts( $query_args, $view_settings, $view_id ) {
    if($view_id == 137) {
		if(is_front_page() and !isset($_GET['wpv_view_count'])) {
			$query_args['meta_query'][] = array(
				'key'     => 'wpcf-destacada',
				'compare' => 'EXISTS',
			);
		}
    }
    return $query_args;
}

Could you please try to add above code to your current theme's functions.php file and check on home page you see only featured posts now.

#618670

I am not sure where I should insert the code you provide.

Please see screenshot attached. Is it ok if I insert the code after "<?php" line and click on "Update"?

Thanks
Daniel

#618963

Minesh
Supporter

Languages: English (English )

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

You should try to add the shared code to your current theme's functions.php file at bottom of the file before PHP tag ends (if it's there)