• Resolved Wayne

    (@waynep16)


    How can I achieve the following in one query / foreach loop on the main blog page?

    CATEGORY TITLE
    – ajaxload more shortcode showing cat 1

    CATEGORY TITLE 2
    – ajaxload more shortcode showing cat 2

    CATEGORY TITLE 3
    – ajaxload more shortcode showing cat 3

    CATEGORY TITLE 4
    – ajaxload more shortcode showing cat 4

    ETC…

    • This topic was modified 6 years, 4 months ago by Wayne.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @waynep16,
    Yes, you could do something like this.

    <?php
    $cat_args=array(
       'orderby' => 'name',
       'order' => 'ASC'
    );
    $categories = get_categories($cat_args);
    // Loop all categories
    foreach($categories as $category) { 
       echo '<h2>'. $category->cat_name .'</h2>';
       echo do_shortcode('[ajax_load_more category="'.$category->slug.'"]');
    }
    ?>

    Hope that helps.

    Thread Starter Wayne

    (@waynep16)

    You’re the man ! works a treat

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Loop posts separated by category….’ is closed to new replies.