- This topic has 3 replies, 2 voices, and was last updated 2 years, 3 months ago by David.
-
AuthorPosts
-
December 20, 2021 at 2:41 am #2054244Frederique
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 ?>
December 20, 2021 at 5:36 am #2054383DavidStaffCustomer SupportHi 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/
December 20, 2021 at 8:49 am #2054701FrederiqueThat 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 !December 21, 2021 at 4:03 am #2055376DavidStaffCustomer SupportThat 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.
-
AuthorPosts
- You must be logged in to reply to this topic.