Skip Navigation

[Gelöst] Filter Results on frontend and back

This support ticket is created vor 4 Jahre, 6 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 9 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luigi Bella vor 4 Jahre, 6 Monate.

Assistiert von: Luo Yang.

Author
Artikel
#1376627
Screen Shot 2019-11-05 at 8.40.26 PM.png
Screen Shot 2019-11-05 at 8.40.13 PM.png

Hi There!

I am trying to: Display all my posts in the following categories: Annual Accomplishments, Fact sheets, Latest stories, News mentions, Videos. I do not want the other post categories to be displayed in the View output.
Then I would like to have a Frontend Filter so visitors can choose what category to see from the options listed above. The problem is that if I add a filter to only display the categories I want, I can't add a frontend Category filter.

I'm also hoping to remove the Default option that displayed All Posts from the Frontend FIlter and have the Latest Posts category be selected and displayed by default, so perhaps I can just use a Frontend Filter for the Categories and there is a way to hide the categories I don't want to be displayed (Uncategorized, Press releases, and Partner Projects)?

Link to a page where the issue can be seen: versteckter Link

Thanks so much for your help!

#1376865

Hello,

Thanks for the details, I can log into your website.

I assume we are talking about the shortcode in post view "Filterable Blog":
[wpv-control-post-taxonomy taxonomy="category" type="select" default_label="All Posts" orderby="count" order="DESC" url_param="wpv-category"]
See our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-post-taxonomy

There aren't such kind of built-in features for both of your requests, they need custom codes, for example, you can use filter hook wpv_filter_query to setup custom PHP function, apply custom taxonomy query to Views, see our document:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

If you need more assistance for it, please provide the FTP access, I need to test and debug it in a live website. Thanks

#1379877

Thank you for your help.

I'm not familiar with using filter hooks so if you'd be willing to continue helping find a solution, I would greatly appreciate it!

I can clone the site to a staging domain so you can freely make changes. Would a File Manager plugin work instead of FTP access?

#1380513

Yes, File Manager will work, I have enabled the private message box again.

#1380677

Thanks Luo Yang!

I have created a copy of the site at dev.pdc.org and installed a File Manager plugin for your use; the login credentials previously created for you should work there as well.

Hope you have a great day!
- Luigi

#1381589

Thanks for the details, I am checking it in your website, will update here if there is anything found.

#1381611

I have done below modifications in your website:
1) Edit the post view "Filterable Blog":
versteckter Link
in section "Search and Pagination", click "JS Editor", setup the JS codes as below:

function specific_terms_func(){
	jQuery('[name="wpv-category"] option').not('[value="updates"], [value="accomplishments"], [value="fact-sheets"], [value="in-the-news"], [value="videos-and-media"]').hide();
}
jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	specific_terms_func();
});
specific_terms_func();

Above JS codes will be able to hide the categories you don't want to be displayed (Uncategorized, Press releases, and Partner Projects)

2) Dashboard-> Toolset-> Settings-> Custom codes:
versteckter Link
Add/activate a PHP file: filter-results.php
with below codes:

add_filter( 'wpv_filter_query', function($query_args, $view_settings, $view_id){
	if($view_id == 243127){
    	if(!isset($_GET['wpv-category']) || empty($_GET['wpv-category']) ){
        	$_GET['wpv-category'] = 'updates';
        }
    }
	return $query_args;
} , 10, 3);

Above codes will be able to achieve:

have the Latest Posts category be selected and displayed by default

Please test again, check if it is what you want. Thanks

#1383133

Thank you for your amazing help!

The Latest Posts category is now successfully being displayed by default, but I'm still seeing the hidden categories when I go to page 2 or later in the results.

And it seems like the Date field is not displaying on the first result of page 2 of the results either, do you know why that may be?

Here is a video: versteckter Link

I appreciate all your help!
- Luigi

Neue Threads, die von Luo Yang erstellt wurden und mit diesem verbunden sind, sind unten aufgeführt:

https://toolset.com/de/forums/topic/date-field-is-not-displaying-on-the-first-result-of-page-2-of-the-results-either/

#1383729

For the question:
but I'm still seeing the hidden categories when I go to page 2 or later in the results.

I have done, below modification in your website:
Edit post view "Filterable Blog":
versteckter Link
in section "Search and Pagination", click "JS Editor", add below JS codes:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
	specific_terms_func();
});

Please test again, check if it is fixed.

For the new problem, please check the new thread here:
https://toolset.com/forums/topic/date-field-is-not-displaying-on-the-first-result-of-page-2-of-the-results-either/

#1387371

My issue is resolved now. Thank you!

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.