Posts Widget - Style Taxonomies, Default Filter

Hello there,

Right now I am running into issue wether I should use a Filter Plugin or the Posts Widget. I like the “fluidness” of the Posts widget, but have troubles to style Taxonomies.

For example:
I have different Terms and I want to show them in single Brackets like [Family] [Journey] [Adventure]. Right now Tax’ are shown this way: Family, Journey, Adventure

The second Question:
The Default “All” Filter seems to be translated in System Language. Since The website is supposed to be in German the Label needs to be “Alle”. The backend and system language has to stay English.

I will show both issues in a picture below:

On the 2nd One is a Custom Query Loop with Search&Filter Pro. It works but the way it works looks and feels outdated since I can’t find much solutions to style the Filter. But there you can see how the Taxonomies look like.

If you can call out a well working Filter Plugin (FacetWP is to Expensive) I would appreciate.

Thanks in advance.

2 Likes

I’m looking in to this as well. No support for now.

Hi

“Filtering” is becoming my fav topic.

First to your question, you can use either a filter called “prefix_facet_choices” or a filter called “replace_facet_content” in GridbuilderWP to exactly do what you want to do with the [Filtername]:

Now to my personal filter experience.

I first used Search&Filter Pro, but I also felt it is outdated. At least thanks to cmstew we can use it in Bricks:

At the moment, I am using PiotnetGrid (PG) and most recently GridbuilderWP (GB).

I have re-done my site with GB as I think it has the slightly nicer interface than PG and as it is faster in the back-end than PG. Both tools are very stable and fast in the front-end.

Here is an example from my site, all done with GB:

If you know a little bit of css, you can make it look really nice.

GB is working perfectly with the Bricks native query loop. PG also works in general, but I had some issues which I could not solve (for example infinity scrolling with PG facet and bricks query loop). But the grids from PG work well in Bricks, so I used them instead of the Bricks native query.

The advantage of PG over GB is that PG offers a very reasonable life-time purchase ($119 lifetime, 100 sites), where GB does only offer annual ($49 per year, 1 site).

I do like the open architecture of PG and I managed to write my own widgets for that tool. That’s why I still keep it around.

The PG support is quick and together we managed to improve even one of their widgets. I did not have to use the GB support, so I don’t know about them.

Overall, I find GB to be my number 1 filtering tool at the moment because of the very good integration with Bricks.

PG is on second place due to the not yet perfect Bricks integration.

Search&Filter Pro is also still there, due to the good price point and because it works now thanks to cmstew.

Cheers

Patric

3 Likes

Hi Patric, you seem to know WPGribuilder well, I’ve a question if I may.

Using WPGridbuilder, I’d like to set up a search box in my header. The idea is that the result of the search query will be displayed in my search results page, which has facets.

I tried using a WPGridbuilder search facet in the header, but that only works if the facet is on the same page as the grid. (not the case of many of my pages).

I tried using the native Bricks search widget. It opens my search results page, but the facets on that page don’t sync with the search query.

I thought it would be simple, but I don’t understand what I can do.

Maybe you have an idea for me? How can I sync a search query and the facets on my result page ?

Thanks !

Hi Bloom

it is possible. We can use the Bricks Posts widget for our case.

Here is the way how it can be done. Maybe there are even better / easier ways, but this one works:

  1. If not already done, add in your header template the standard Bricks Search widget. I used the input type search field.

Search Results2

  1. If not already done, create the Search Results Template in Bricks.

  2. You can add / design the Search Results Template page however you want, BUT in minimum, it needs to have this structure:

Search Results4

I add the Bricks Post Widget but I do not make any changes or adjust anything in the query settings of the post widget, I leave everything the way it is:

  1. The Facet in the structure is the WPGridbuilder Facet. You can add here your desired facets.

In the Facet settings, when you click on “Select a grid or element…” you should see the Bricks posts widget as a selection.

  1. Now, when you enter something in the search widget in the header of a page, the Search Results Template Page is called and the WPgridbuilder Facets are working.

Note: There are a few discussions in the Bricks forum about the Bricks search widget and its results…

It seems that the search widget is not always finding all results from custom post types. If you have this issue, maybe it helps to first look at the query details, you can do it like this:

I personally don’t use the Bricks search widget and I also don’t use the search results page. I use my own Ajax search form.

But maybe you first start and then see how far you get with your search results.

Cheers

Patric

Update 22. February 2023:

With Bricks V1.7, the posts-merge_query filter is not necessary anymore. I therefore deleted the unnecessary steps in the process below.

‘gfpkfh’ is the Container element under everything else is included; all the facets, the query and the layouts.

The WPGridbuilder Facets under this main Container element ‘gfpkfh’ all have my query block in the “Select a grid or element to filter”, in my case it is #iblqce.

Search Results10

My query #iblqce:

Search Results11

In my query, I defined that I only want to see results that are in the custom post type “Rezepte” and I also defined the sorting:

Search Results13

That’s it. When I search for something via the Bricks search widget in the header, the Bricks Search Results template page is shown with my own query, my layout and the WPGridbuilder facets:

So it is possible to link the WPGridbuilder Facets and a custom query with the Search Results Template.

Cheers

Patric

Wow thank you so much for this very detail answer ! Very kind of you !

Now, I am going to try.

Have a nice day, thanks again.

No, I have to thank you, because your question made me look into the merge_query filter and now that I got it working so nicely with the WPGridbuilder Facets and my own query, I will actually implement this into my page.

So thank you and let me know if you have any problems.

Cheers

Patric

I really like WPGribuilder, best solution on the market for Bricks users, but man the documentation is a bit rough and so is the support. They should hire you.

1 Like

Update.

If you have a WPGridbuilder Search facet in your Bricks search results page and want that this Search facet shows the terms / words / whatever the user entered in the Bricks search form widget when the results page is loaded:

Then you can use this code (for example add it into a WPCodeBox snippet):

 <?php 
function prefix_filter_query( $query_string, $grid_id, $action ) {

	// If we are on the search results page and a search parameter exists
	if ( 'render' === $action && is_search() && isset($_GET['s']) ) {
		
	$suchkey = htmlspecialchars($_GET["s"]);
	$suchkey = sanitize_text_field( $suchkey );
	        if (!empty($suchkey)) { 
			$query_string = [
			'rezept_stichwortsuche_2'   => [ $suchkey ]
			         		];
       }    
       }
      return $query_string;
}
add_filter( 'wp_grid_builder/facet/query_string', 'prefix_filter_query', 10, 3 );

This code is using the very powerful “prefix_filter_query” function from WPGridbuilder.

Just replace the “rezept_stichwortsuche_2” with the facet slug from the “Naming” setting in the WPGridbuilder facet settings:

Note: I made this check in the code

if ( 'render' === $action && is_search() && isset($_GET['s']) ) {

so that the Search facet is only filled with the search terms if the page is a search page and if there is a search parameter (=“?s”) in the url of the page. This makes sure that only the Search facet on the search results page is getting updated.

You can of course change that code line.

Cheers

Patric

1 Like

Thanks again Patrick.

I’m facing a new problem, if you have time. It’s not directly about WPGridbuilder, but it’s related to it.

My search results page is working fine. But when there are no results, I get this message:

What I would like to achieve is :

If WpGribuilder doesn’t return any results, then I want Bricks Builder to put something like a “display: none” on the WPGribuilder section of my page, and display instead my “If no results” section (this section is hidden otherwise).

I hope I’m making sense. :slight_smile:

screenshot-www.aboutfilament.fr-2023.02.18-17_06_19

I’ve tried playing with the “conditionals” functions in Bricks, but no success.

Do you have any idea about how to achieve this?

Thanks

Hi

You can use the WordPress function have_posts().

In your condition, select Dynamic Data, in the dynamic data field type

{echo:have_posts()}

and in the condition field use

==

and in the value field use

1

This condition will be true (=1) if have_posts() returns true, which means there are posts to be looped through.

So use the condition above for all elements you want to show if matching posts were found.

This should work.

Cheers

Patric

Thank you so much, works like a charm !