Search code examples
wordpressadvanced-custom-fields

Display no result content - custom type


I create a custom type with ACF (Wordpress)

I would like to display a 'no result message' if no content in a category

my code

<?php
        $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
        $loop = new WP_Query( array( 
                'post_type' => 'event',
                'posts_per_page' => -1,
                'paged'          => $paged )
        );
        if ( $loop->have_posts() ):
        while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <div class="container-fluid" id="events" itemscope itemtype="https://schema.org/Event">
        <div class="row row-eq-height align-items-center alignrow">
            <div class="col-md-12">
                
            </div>
            
            
        </div>
    </div>
        <?php endwhile; ?>
        <?php wp_reset_postdata(); ?>
    
        <?php endif; ?>

Solution

  • ok found it

    <?php
            $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
            $loop = new WP_Query( array( 
                    'post_type' => 'event',
                    'posts_per_page' => -1,
                    'paged'          => $paged )
            );
            if ( $loop->have_posts() ):
            while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <div class="container-fluid" id="events" itemscope itemtype="https://schema.org/Event">
            <div class="row row-eq-height align-items-center alignrow">
                <div class="col-md-12">
                    
                </div>
                
                
            </div>
        </div>
            <?php endwhile; ?>
            <?php else: ?>
            no result here
           <?php endif; ?>