Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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.

    #1328792

    Hey 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,
    Mike

    #1328883
    This reply has been marked as private.
    #1328893

    Hi,
    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,
    Mike

    #1329140

    Thank you very much Mike! I guess this workaround would work. Thank you!

    #1329146

    Hi,
    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

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Masonry empty categories show other categories’ is closed to new replies.