Home Forums Gutenberg Gutenberg Block with ACF Pro – By taxonomy


Gutenberg Block with ACF Pro – By taxonomy

  • Hello everybody !

    I based myself on this tutorial to create a Gutenberg block and display my custom post type “Projects”.

    I would like to adapt it for another custom post type “FAQ”.
    We would, as in the previous one, be able to search for specific posts. And I would like to add the possibility of displaying all the posts by filtering with one or more taxonomies.

    Would anyone see how to do it?

    I tried the code below but Gutenberg doesn’t seem to save it. When I want to edit my page on which I added the block and selected a taxonomy, my filter is empty.

    $argType = get_field( 'faqs_loop' );
    if( $argType == "count" ) :
        $topics = get_field( 'faqs_categories' );
      $args = array( 
        'orderby' => 'title',
        'post_type' => 'faq',
        'tax_query' => array(
                'taxonomy' => 'categorie_faq',
                'field' => 'slug',
                'terms' => $topics,
      $faqs = get_field( 'faqs_select' );
      $args = array( 
        'orderby' => 'title',
        'post_type' => 'faq',
        'post__in' => $faqs
    $the_query = new WP_Query( $args );
        <div class="site_list_post col-12 faq">
            <div class="d-flex row">
            <?php if( $the_query->have_posts() ) : while( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <article class="post col-12 mb-30">
                            <?php the_title(); ?></a>
                        <?php the_content(); ?>
                        <?php the_terms( get_the_ID() , 'categorie_faq' );  ?>
        <?php endwhile; ?>
        <?php endif;?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.