• Resolved markelrayes

    (@markelrayes)


    I’m on a localhost so I can’t show the page but:

    My company bought ALMPro and the filter plugin.

    I have multiple ALM Shortcodes firing with this code:

    <?php echo do_shortcode(‘[ajax_load_more id=”story-hub” target=”category_listing” filters=”true” post_type=”stories” posts_per_page=”2″ taxonomy=”‘ . $hubfocustype . ‘” taxonomy_terms=”‘ . $hubfocus . ‘” taxonomy_operator=”IN” repeater=”template_3″ destroy_after=”1″ placeholder=”true” meta_key=”featured_story” meta_value=”0″ meta_compare=”IN”]’); ?>

    And the other:

    <?php echo do_shortcode(‘[ajax_load_more id=”story-hub” target=”category_listing” filters=”true” post_type=”stories” posts_per_page=”6″ taxonomy=”‘ . $hubfocustype . ‘” taxonomy_terms=”‘ . $hubfocus . ‘” taxonomy_operator=”IN” repeater=”template_4″ scroll=”false” offset=”2″ button_label=”More Stories” button_loading_label=”Loading”]’); ?>

    And my filter is:

    [ajax_load_more_filters id=”category_listing” target=”story-hub”]

    Problem:

    The filter works perfectly fine if I only have one ALM as the ID. If it has two, it returns the results twice inside the first ALM. The second one is empty. Unless I refresh the page then it works how I wanted it to.

    Is there a way to filter two ALM with the same IDs with one filter?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter markelrayes

    (@markelrayes)

    Please ignore the $hubfocus and $hubfocustype. They define what kind of post taxonomies to load and work perfectly.

    Plugin Author Darren Cooney

    (@dcooney)

    @markelrayes You can only filter 1 instance of ALM with Filters addon.

    You could potentially work around this using the pubic Filter method, but it really depends on what exactly you’re trying to do.

    —-

    FWIW – I’ve been working on adding functionality for this for a while, to be able to add multiple and it’s nearly complete. Not sure when it would be released so this doesn’t help short term.

    Thread Starter markelrayes

    (@markelrayes)

    One solution I am thinking is to create a variable like $filters and have it just a comma separated list of what is checked. So if they check option A and B the $filters would echo “A, B” and from there have it do a meta query filter on the actual ALM shortcode.

    Like:

    meta_key=”filter_choice” meta_value=”$filters” meta_compare=”IN”

    That way I can put $variable into multiple ALMS. Would that work?

    I have to figure out the ajax to define the variable when the user clicks the checkboxes.

    Thread Starter markelrayes

    (@markelrayes)

    It would actually be meta_value=”. $filters .”

    Plugin Author Darren Cooney

    (@dcooney)

    @markelrayes

    That way I can put $variable into multiple ALMS. Would that work?

    I’m really not sure what you mean by this. Are you still talking about filtering two instances of Ajax Load More with a single filter?

    Plugin Author Darren Cooney

    (@dcooney)

    I think you may want to skip using the Filters add-on and use the Public filtering method here
    https://connekthq.com/plugins/ajax-load-more/docs/public-functions/#filter

    This way you could target two instances with a custom filter.

    Thread Starter markelrayes

    (@markelrayes)

    I think that might be the solution thanks. I’ll look into it.

    What I was thinking was using the custom meta query function built into the shortcode builder but having the value be a php variable that is updated on page load through Ajax.

    So when the page loads the php variable for the meta query value is updated page-wide.

    Thread Starter markelrayes

    (@markelrayes)

    Dcooney,

    Does that Public Filtering method you provided work if multiple check boxes are selected or is it just for one button at a time?

    BTW the site is at new.connectcre.com

    I have the filters just showing at the top right now to get an idea of what I mean.

    • This reply was modified 3 years, 10 months ago by markelrayes.
    Thread Starter markelrayes

    (@markelrayes)

    Hey,

    This was the final code to filter multiple queries:

    echo do_shortcode('[ajax_load_more single_post="true" single_post_id="' . get_the_ID() . '" single_post_order="query" single_post_query_order="latest" repeater="template_6" post_type="stories" meta_key="other_property_sectors:story_topics" meta_value="' . $propertysector . ':' . $filtertopics . '" meta_compare="LIKE:LIKE" meta_relation="AND" meta_type="CHAR:CHAR" scroll_distance="-500" posts_per_page="1" taxonomy="story-market:property-sector" taxonomy_terms="' . $filtermarkets . ':' . $filtersectors . '" taxonomy_operator="IN:IN" cache="true" cache_id="sector-stories" ]');

    Is that going to put a giant strain on my server?

    Plugin Author Darren Cooney

    (@dcooney)

    Doubtful. This just creates a WP Query from the shortcode params.

    Thread Starter markelrayes

    (@markelrayes)

    Cool. So I used this meta and taxonomy filters on multiple ALM shortcodes on the same page so when I change the variables they filter all of them.

    One last question, if there are no values given for the taxonomy terms and meta keys, will it still search the WP Query and return nothing or does it ignore that empty query?

    Plugin Author Darren Cooney

    (@dcooney)

    Depends on if you are using AND or OR operators in the meta and tax queries.

    Thread Starter markelrayes

    (@markelrayes)

    Cool, thanks for the helpful tips. Our site is live at https://www.connectcre.com and we use ALM for the load more stories and the main story page. It’s been really helpful. Thanks for being responsive.

    Plugin Author Darren Cooney

    (@dcooney)

    Awesome! Always glad to hear that ??

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Filter multiple ALM Categories’ is closed to new replies.