-
AuthorPosts
-
November 12, 2021 at 3:46 am #1328712
Hey, Enfold team.
Do you guys have a better solution for this issue?
We have the same problem. Our client has two pages. One shows Events (posts) Category 1 and the other one shows Events (posts) Category 2. When there is no Events (posts) Category 2 the page shows all the Events (posts) Category 1. We don’t want that. We just don’t want that page to show any Events (posts). It would actually be great to show a custom message something like “No current events.” when there is no Events (posts) created under specific category.
There was the same question in the forum 2 years ago (https://kriesi.at/support/topic/masonry-empty-categories-show-everything/) but there was no good support/solution provided.November 12, 2021 at 2:27 pm #1328792Hey levlaneadvertising,
Thank you for your question and the link you the similar question, but that question was using multiple masonry elements on the same page, as I understand your question you are using two pages, but I’m not sure which elements you are using, when you write “Events” do you mean The Events Calendar plugin or are you using the blog element displaying simple “posts” that you are calling “events”?
Please create example pages using the elements and layout you intend to use and an admin login to test with.
In your similar issue link, Ismael points out that this is an “empty array” issue, if so I believe that one way around this would be to compare the item categories with the category you want to show on the page and hide non-matching ones, and if none are showing display a message like “No current events.”
But I won’t be sure this is possible until I see the elements and if the post categories are being passed to the page, otherwise perhaps using post “tags” to choose what is displayed would be an option.Best regards,
MikeNovember 13, 2021 at 6:06 pm #1328883This reply has been marked as private.November 13, 2021 at 9:33 pm #1328893Hi,
Thank you for the link to your site and the explanation, for this one page/memory-care-learning-center/events/
page-id-2047
we will use css to hide any masonry elements with the class tribe_events_cat-independent-living
then we will use a jQuery script to check if no masonry elements are showing, and if so we will display a message.
Please add this code in the General Styling ▸ Quick CSS field or in the WordPress ▸ Customize ▸ Additional CSS field:#top.page-id-2047 #av-masonry-1 .tribe_events_cat-independent-living { display: none; } .nocat { text-align: center; color: #fff; font-size: 20px; }
Then add this code to the end of your functions.php file in Appearance ▸ Editor:
function custom_nocat_script() { ?> <script> (function($) { var nocat = $('<div class="nocat">No Current Events</div>'); if($('#top.page-id-2047 .av-masonry-entry').is(':hidden')){ $(nocat).appendTo('#av-masonry-1'); } })(jQuery); </script> <?php } add_action('wp_footer', 'custom_nocat_script');
Best regards,
MikeNovember 15, 2021 at 11:40 pm #1329140Thank you very much Mike! I guess this workaround would work. Thank you!
November 16, 2021 at 1:27 am #1329146Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Masonry empty categories show other categories’ is closed to new replies.