![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
Tagged: empty, masonry, no entries, no items, result
-
AuthorPosts
-
September 7, 2023 at 12:30 pm #1418356
Hi team Enfold,
If the masonry element contains no entries, other entries (like for example pages) will be displayed.
Is there a way to just let the masonry element empty, if there are no results?We found this but it seems incomplete.
add_filter('avf_masonry_query_no_entries_fallback', true, $terms, $valid_terms );
Kind regards,
Team VDLPSeptember 8, 2023 at 12:41 pm #1418451Hey vdlpwp,
Thank you for the inquiry.
Adding the following code in the functions.php file should work.
add_filter('avf_masonry_query_no_entries_fallback', '__return_false');
Best regards,
IsmaelSeptember 15, 2023 at 10:42 am #1419256Hi Ismael,
Thank you for your answer. The supplied code doesn’t have any effect.
The masonry grid still shows (other) entries, when there are no entries (in the selected category).
Kind regards,
Team VDLPSeptember 15, 2023 at 11:11 am #1419262Hi,
Thank you for the update.
The filter works correctly on our end. Please provide the site URL and login details so that we can check the issue further. Did you purge the cache before checking the page?
Best regards,
IsmaelOctober 2, 2023 at 2:05 pm #1421139This reply has been marked as private.October 2, 2023 at 3:39 pm #1421154Hi,
Thank you for the info.
We were not able to edit the functions.php file because the Appearance > Theme File Editor is not accessible. Please enable the editor or post the S/FTP details in the private field.
Best regards,
IsmaelNovember 23, 2023 at 10:01 am #1426327This reply has been marked as private.November 24, 2023 at 11:25 am #1426393Hi,
Thank you for the info.
Did you enable the .htpassword? We can’t access the site because it is requiring another authentication. Please provide the info in the private field and try to add the filter again in the functions.php file.
add_filter('avf_masonry_query_no_entries_fallback', function($fallback) { return false; }, 10, 1);
Best regards,
IsmaelNovember 30, 2023 at 12:04 pm #1426792Hi Ismael,
Our apologies. We added the authentication credentials in above private reply.
Best regards,
Team VDLP-
This reply was modified 9 months, 1 week ago by
vdlpwp.
December 2, 2023 at 2:05 pm #1426956Hi,
When I test the filter that Ismael posted above on my test site child theme functions.php and test a masonry element for a specific category, and set all of the items to “draft” the masonry element is not included in the page source code and it shows no items until I publish one of the posts for the specific category.add_filter('avf_masonry_query_no_entries_fallback', function($fallback) { return false; }, 10, 1);
So this filter seems to be working correctly, when I examine your site you seemed to also be tring to show posts in a masonry element, but you didn’t have a category selected:
thus on the frontend the masonry element showed some “pages” instead of “posts”
so I selected the category in the masonry element:
and now on the frontend the masonry doesn’t show any items:
the title and button show because they are separate elements:
Please check.Best regards,
MikeDecember 4, 2023 at 3:00 pm #1427137on my test environment – this is standard behavior.
if there are no entries there is no masonry shown.
Only an element ( here it is a heading ) got the class: el_before_av_masonry_entriesDecember 4, 2023 at 3:24 pm #1427139Hi Mike,
Thank you for your detailed answer. To elaborate further on your answer, we wonder whether it is possible to add a filter that does not return any entries if there are no results (when no category in a certain taxonomy is selected).
When a blog has multiple categories, we won’t select a category (within the taxonomy ‘Category’) so everything is shown regardless of a specific category.
Thanks in advance
Team VDLPDecember 4, 2023 at 11:19 pm #1427171Hi,
If you had multiple categories then the category with posts would be the one to show and you would not need to use the filter above.Best regards,
MikeJanuary 25, 2024 at 2:55 pm #1432023Hi Mike,
Thank you for your reply. Our apologies for our late response.
… masonry element, but you didn’t have a category selected:
This is correct. We don’t want to select a category in our masonry element. So when there are 3 categories, and in the future our client adds another category, this post (from this new category) will also be shown.
But when we select ‘no categories’ and there are no posts, all pages and sort of post type entries are shown in the masonry. This should in our opinion result into 0 items. Because there are post categories, but there are no posts in this categories.
Is there also a filter or function for this?
Desired situation: When no categories are selected the masonry element has 0 results. When a new post is added in a new category, it shows 1 post.
Kind regards,
Team VDLPJanuary 26, 2024 at 9:59 am #1432103Hi,
Desired situation: When no categories are selected the masonry element has 0 results. When a new post is added in a new category, it shows 1 post.
That is not possible, unfortunately. You either have to select a category or select none at all to display all posts from all categories. The filter avf_masonry_query_no_entries_fallback when set to false will prevent fallback posts from displaying when there are no items in the selected category.
Best regards,
IsmaelMarch 27, 2024 at 11:00 am #1438421i know that this is an older topic – but with that new logic to show only Cat A and Cat B if both is true. Filter does not work as expected.
It shows the posts of that Category which has a post.March 30, 2024 at 7:54 pm #1438773Hi,
Thanks for pointing this out Guenni007, I summited a report to the Dev Team and will reply when I hear from them, thank you for your patience.Best regards,
MikeApril 1, 2024 at 1:19 pm #1438894Hi @Guenni007,
I added a fix for 5.7:
LIMITATION: relation “AND” does not provide a fallback if empty categories are selected !!!
Best regards,
GünterApril 3, 2024 at 1:04 pm #1439078LIMITATION: relation “AND” does not provide a fallback if empty categories are selected !!!
means in the case of the And combination, if one of the categories contains no posts, nothing is displayed. – which would be my personal preference.
April 7, 2024 at 6:54 pm #1439423Hi,
means in the case of the And combination, if one of the categories contains no posts, nothing is displayed. – which would be my personal preference.
This is how it is working for me when I check and using the filter:
add_filter('avf_masonry_query_no_entries_fallback', function($fallback) { return false; }, 10, 1);
this was the intention of the fix.
Best regards,
Mike -
This reply was modified 9 months, 1 week ago by
-
AuthorPosts
- You must be logged in to reply to this topic.