[Support request] Need to allow results from search in a custom Gutenberg block

Home Forums Support [Support request] Need to allow results from search in a custom Gutenberg block

Home Forums Support Need to allow results from search in a custom Gutenberg block

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2054244
    Frederique

    Hithere!
    We add a custom block like an accordion in pages but we need some advice to get search from their content.
    For e.g when we have some search here > https://www.colormyweb.pro/Buxerolles/?s=dechet
    the first result is the title of the concerned page but we notice we can’t load some results from the content in the tabs with other searching requests.

    Accordion blocks have been built with ACF and nothing very special about that…

    In summary, how could we get some queries from accordion tabs ?
    Thanks a lot for helping understanding the best way to do so 🙂

    —-

    (see code in the view maybe helps)

    <?php
    /**
     * Affichage du HTML dans le block
     *
     * @package acf-gutenberg-blocs
     * @author Colormyweb
     * @since 1.0.0
     */
    
    // create id attribute for specific styling
    $cmw_acc_id = 'cmw-accordion-' . $block['id'];
     
    if( !empty($block['anchor']) ) {
        $cmw_acc_id = $block['anchor'];
    }
     
    // Create class attribute allowing for custom "className" and "align" values.
    $cmw_className = 'cmw-accordion';
    if( !empty($block['className']) ) {
        $cmw_className .= ' ' . $block['className'];
    }
    if( !empty($block['align']) ) {
        $cmw_className .= ' align' . $block['align'];
    }
    
    $align_class = "";
     
    //get repeater field name
    if( have_rows('accordion') ): ?>
        <div class="<?php echo esc_attr($cmw_className); ?> <?php echo $align_class; ?>" id="<?php echo $cmw_acc_id; ?>">
            <?php
            //whilst we have repeating fields
            while ( have_rows('accordion') ) : the_row(); 
                //vars
                $acc_title = get_sub_field('accordion_title');
                $acc_content = get_sub_field('accordion_content');
                ?>
                
                <h2 class="cmw-acc-title">
                <?php echo ($acc_title); ?>
                </h2>
    
                <div class="cmw-acc-panel" style="display: none;">
                <?php echo wp_kses_post($acc_content); ?>
                </div>				  
                
            <?php endwhile; ?>
        </div>
    <?php endif; // end accordion ?>
    #2054383
    David
    Staff
    Customer Support

    Hi there,

    WordPress won’t parse nested block content when it creates the Excerpt.
    You can see some more info here and the link to the related core.trac of the bug:

    https://generatepress.com/forums/topic/excerpt-blank-for-some-generateblocks-combinations/

    #2054701
    Frederique

    That means content is not shown ?
    I’m not an expert and try to get it…
    What’s the gab btw Excerpt and Search results ?
    Thanks !

    #2055376
    David
    Staff
    Customer Support

    That means content is not shown ?

    Yes, thats correct.

    This is the bug report here:

    https://core.trac.wordpress.org/ticket/47637

    Until that is resolved, Excerpts will only display content that are Top Level blocks. Anything that is placed inside another block, such as a Group Block, a GB Container Block or your custom ACF Accordion Block cannot be included in the Excerpt.

    And as Search Results show the Title and the Excerpt you won’t see that content in the search field either.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.