Skip Navigation

[Resolved] image custom field as view query filter

This thread is resolved. Here is a description of the problem and solution.

Problem:
The customer wanted to display only posts with a custom image field in her view. However, when attempting to add a filter for this custom image field, it was not listed, nor were any other custom image fields.

Solution:
After further investigation, it was confirmed that the custom image fields not appearing in the filter section is expected behavior. We suggested using a wpv-conditional shortcode to test if the image exists as a workaround and provided a link to additional code that could help. Rita decided to rework the website to make images a required element when creating profiles.

Relevant Documentation:
https://toolset.com/forums/topic/view-query-filter-for-whether-an-image-custom-field-has-content/#post-1984439

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 5 replies, has 2 voices.

Last updated by Mateus Getulio 4 months, 3 weeks ago.

Assisted by: Mateus Getulio.

Author
Posts
#2710477
Screenshot 2024-07-29 at 19.13.55.png

Hi there
I have a view where I only want to display posts that have a custom image field. That is 'custom-image-field' is DIFFERENT from ' '.
The field belongs to my 'media group' custom field group - see attached screenshot. Its very strange but in this view and any other view on this site, when I click 'add a new filter' the image custom field I wish to filter by is not listed, nor are any of the other custom image fields... I don't know why not...
Hoping you can point me in the right direction.
Rita

#2710622

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Rita,

Thank you for contacting us and I'd be happy to assist.

It is possible that this is happening due to a conflict issue, could you please try to test this problem in the minimal environment,
To do that, Please disable all non-Toolset plugins and activate a default theme (Twenty Twenty Three for example) . And then see if the problem exist.

If it doesn't work, I'll need to see how this CPT and view is set up in the admin area and to debug it closely.

Can you please share temporary admin login details along with a link to a page where this view can be seen?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Mateus

#2710652

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Rita,

Thank you for sharing that information.

I checked this but so far I couldn't find a fix for it.

I'd like to ask permission to make a copy/staging version of your site where I can debug this closely without affecting the live site.

I'll make sure to delete this copy as soon as we get this issue fixed.

I'm afraid of debugging directly on the live site and cause issues to your visitors. Also, it is important to test a different setup as part of the troubleshooting.

Thank you, please let us know.
Mateus

#2710695

Hi Mateus
I completely agree and have set up a staging site already.
Please give me a private reply so I can send you access credentials.
Rita

#2710763

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Rita,

That's perfect, thank you for doing it.

Your next reply is marked as private.

Best,

#2710889

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Rita,

Thank you for your patience while I investigated it. I tested this on a fresh new WordPress install with Toolset and I figured out that this is the expected behavior for the custom image fields not show up in the filter section among the other custom fields.

I'm going to check internally if it is possible to implement it or suggest as a feature request, but as a workaround in the meantime you could use a wpv-conditional shortcode to test if the image exists or implement the code my colleague shared here after replacing the custom image field name:

https://toolset.com/forums/topic/view-query-filter-for-whether-an-image-custom-field-has-content/#post-1984439

#2711063

Thanks very much for taking a look Mateus.
I have already tried the option to add that filter to functions.php but it breaks all the other search filters in the view. I have now reworked the way the website manages profiles in general and made images a required element when the user creates a profile. This is not what we were aiming for but it will have to do.
I'll close this ticket now.
Thanks again.
Rita