Skip Navigation

[Resolved] Featured listing (post) view with a checkbox doesn't load anything

This support ticket is created 4 years, 4 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 4 replies, has 2 voices.

Last updated by jean-francoisB 4 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1402335
4.png
3.png
2.png
1.png

I am trying to: Create a Featured listing view that show only the listings with the custom field Featured listing checkbox checked (value = 1). I have created a Custom checkbox field for my listing. When the checkbox is checked, the value is 1 and when is unchecked, it's 0.

Link to a page where the issue can be seen: hidden link

On this page, you can see listings from Health Coaching category. The name of this view is : Listing Archive view. I have create a copy of this view that I named : Featured listing. I have put the Featured listing view at the top of the Listing Archive view, right before the sorting dropdown menu with this code : [wpv-view name="featured-listing"]. If I keep the Featured listing view with the exact same setting of Listing Archive view, the listing result are showed twice on the page. So that make sense and proof that the view is working. So I have added a filter for the Featured Listing view like this :

Select items with field:
Featured listing is a number equal to 1

So normally, I should be able to get as result for this view all listing where I have checked the checkbox Featured listing. But nothing is showed.

And I would like to add the same kind of filter for the Listing Archive view to make sure that the featured listings are not showed in the regular listing. So I have added this filter to this view like :

Select items with field:
Featured listing is a number equal to 0

And now I'm getting 0 result on every category page. So the filter for the checkbox doesn't work or at least, doesn't recognize de value from the checkbox custom field.

What I'm doing wrong here?

Thank you very much!

#1402767

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

Could I get some more details about how you set up these archive pages?

You are not using Toolset custom WordPress archives.

I briefly tested that on your site, and that worked as expected when inserting the Featured Listing View into the custom archive for listing-categories, the featured listing(s) were shown at the top of the page.

I turned on the debug info for Views and the query appears to be set up correctly, I can't see why it is returning no results, but it seems to be related to the specifics of how you set up the archive, if you could please clarify.

#1403369
8.png
7.png
6.png
5.png

Hi,

I'm using Elementor to create the Archive template and I'm embeding the Toolset View using the drag and drop Toolset View from Elementor.

I did some change and it's seems to work better. Please have a look at the page : hidden link

You can see "Patient Patways" listing at the top. That's the Featured listing View and it's supposed to show that listing. This is working fine now. For the Archive listing View, I want everything else from that category except the featured listing. So I have added in the sorting for this view this setting :

Select items with field: Featured listing is a number different from 1

But it shows only one listing instead of everything except "Patient Patways". I don't understand why this is acting like this.

Thanks,

#1403855

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I double-checked your settings. Unlike your screenshot, it shows that the checkbox field is set to save nothing to the database when unchecked.

I looked in the database and confirmed that to be the case, that a listing that does not have the checkbox checked has no entry for the custom field.

Unfortunately, the way that WordPress queries work, if you have a query with a condition that some post meta field does not equal some value the results will skip posts where there is no such key, which is what is happening in this case.

Your settings need to be that 0 is saved to the database, and the posts need to actually have that value saved to show up in the results when applying such a filter.

You need to update the custom field settings so that 0 is saved, and then you will need to re-save your posts so that the database is updated with zero for those posts.

#1407855

Thank you very much for your help! I will change the setting to store 0 in the database. But for now, I have over 1000 listings in the database. So I guess, the best option that I have is updating the field for all these listings via SQL query in PHPMySQL. I should be able to do that. Thank you!

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