Viewing 1 replies (of 1 total)
  • Plugin Author Erick Danzer

    (@edanzer)

    Hi @bradthebluefish

    Are you displaying your category / taxonomy terms as part of a filter? Or are you trying to simply display and ajax loaded / infinite-scroll-style list of categories / terms?

    For now, I assume it’s the first. If so, I’m also wondering if you’re already using the ALM Filters add-on?

    If you are, and you’re displaying a category-based filters, you are right that will normally filter out empty categories. You can you prevent it by doing so by setting ‘hide_empty’ => false as a custom arg. But to do that, you’ll need to use the custom alm_filters_[id]_[key] filter. Docs for that are here: https://connekthq.com/plugins/ajax-load-more/docs/add-ons/filters/hooks/

    But a simple example might look like this, assuming I’ve created a filter called ‘my_filter’ and I’m filtering by category.

    add_filter( 'alm_filters_my_filter_category', function() {
    $values = []; // Define empty array.
    $args = array(
    'hide_empty' => false
    );

    $terms = get_categories($args); // Get all categories.

    // Loop terms.
    if($terms){
    foreach( $terms as $term ) {
    $values[] = array(
    'label' => $term->name,
    'value' => $term->slug
    );
    }
    }

    return $values; // Return values
    });
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.