Skip to content

CPTUI Loop

Usage PHP/HTML:

    <!-- Cpt UI loop -->
    <?php
        // Initialize the custom post type
        $args = [
            'post_type' => '*',
            'posts_per_page' => -1,
            'post__not_in' => array(get_the_ID()),
        ];
        $yourQuery = new WP_Query($args);
    ?>
    <!-- Content here -->
    <?php
        if ($yourQuery->have_posts()):
            while ($yourQuery->have_posts()):
                $yourQuery->the_post();
                // Do something...
                ?>
                    <!-- Content here -->
                <?php
                wp_reset_postdata();
                // End loop.
            endwhile;
            // End if.
        endif;
    ?>