• Hello, I am consulting the plugin documentation to adapt the plugin to “related products” of woocommerce but no matter how hard I try the code does not work.

    I am trying with this:

    <? php
    // Related Posts
    $ terms = wp_get_post_terms ($ post-> ID); // get current categories
    $ term_array = []; // Create empty category array

    foreach ($ terms as $ term) {// Loop founf categories
    $ term_array [] = $ term-> slug;
    }

    // Render Ajax Load More shortcode
    echo do_shortcode (‘[ajax_load_more category = “‘. implode (“, “, $ term_array). ‘” post__not_in = “‘. $ post-> ID. ‘”]’);
    ?>

    Could you help me in this regard? Greetings.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    @areleases Just checking, did you set your post_type to products?

    Thread Starter areleases

    (@areleases)

    Thanks for the quick answer, mmm yes, also try rendering the shortcode with the code of another user:

    echo do_shortcode (‘[ajax_load_more’. $ term_array. ‘post__not_in = “‘. $ post-> ID. ‘” post_type = “product” posts_per_page = “3” scroll = “false” progress_bar = “true” progress_bar_color = “blue” images_loaded = “true” button_label = “Load More” css_classes = “related-posts-container” button_loading_label = “Loading More” container_type = “div”] ‘);

    But doing so loads the list of products without filtering them as “related products”.

    Plugin Author Darren Cooney

    (@dcooney)

    @areleases Sorry missed your reply. Im guess the array of product IDs you are passing is not correct.

    It looks as if your passing products IDs to the category parameter… where you should be passing them to the post__in parameter.

    https://connekthq.com/plugins/ajax-load-more/docs/parameters/

    Also, consult the shortcode builder if you need assistance with constructing the shortcode.

    Hope that helps.

    Plugin Author Darren Cooney

    (@dcooney)

    Closing this for now. Let me know if you still require assistance ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocommerce Related Products’ is closed to new replies.