Skip Navigation

[Résolu] Problem with query filter

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 4 réponses, has 2 voix.

Last updated by Eric Il y a 7 années et 11 mois.

Assigned support staff: Caridad.



I have a site that's importing a list of Job posts from an external feed. Once the Jobs are imported (as custom post types), my client can manually select a radio button (created with a custom field group) to flag certain Jobs as Featured. The default selection configured in the custom field is "no".

I need to display two lists in my sidebar. The first list shows the 5 most recent Jobs flagged as Featured. The next list simply shows the 5 most recent Jobs that are NOT featured, because we don't want repeats in the second list.

I created two Views. One view queries the Jobs cpt, with a query filter to Select posts with custom fields: Featured Job = 2. I made an identical View, but changed the filter to read: Select posts with custom fields: Featured Job != 2.

The view displaying featured jobs works; it only displays featured jobs. The view that supposed to display everything BUT featured jobs doesn't. It returns no results. If I remove the filter from the second view, all the jobs get displayed, and featured jobs get repeated in that list.

What am I missing?



It looks like the default "1" for "no" isn't getting saved to the database when the posts are imported, which means I can't filter with it. So, I decided to try a different approach, using a simple checkbox instead which is specifically configured to write 0's to the database if nothing is checked. I deleted all the posts, reimported them, but am not seeing the 0's written to the database. If I check the box for a post, however, the 1 does get written and I can filter with it. What's the deal with the 0's not being written? And why does the filter fail if i use != 1?

I found this post:
Seems like a similar problem.


Hi Caridad,
I see you're assigned to this topic, so I'm sending you login credentials just in case you ask for them while I'm away. It's 1:30AM my time, so I'm calling it a night.


Dear Eric,

The settings for storing a zero has effect when you are editing the job post, not when its imported. I think that the task of setting a zero for non-featured jobs should be done by the import procedure. Can you describe how you are importing the job feed into WordPress? Are you able to import the featured field with a zero during this process?



I'm using the WP All Import plugin (very handy plugin, btw). When I initially configured the options for the import, the custom field for Featured wasn't appearing in the list of available fields to target for processing--I was thinking the same thing you were, that it needed to happen on import, but that particular field wasn't appearing with its wpcf brothers and sisters. Anyway, I presumed that the 0 insert would happen when each post was officially published during the import. Obviously not so.

Fast forward to this morning. I logged back into WordPress, opened the configuration for the import and lo-and-behold the custom field for Featured was suddenly appearing. Not sure why logging out and in would make that happen, but there ya go. I added it to the import, gave it a value of 0, and it worked!