Hi,
There are 2 issues with ID’s.
First:
Copy block is really cool feature in Gutenberg, and clients/users are using this really often.
The copied block is having the exactly same ID as the original block – which is an issue ofc. The new block won’t open, won’t work.
I’d suggest to generate ID based on the content and add timestamp during block creation or smth.
Second:
Missing ID, This one I’m not sure how my client was able to do. But many blocks are missing the ID so they are not working.
I’d suggest to check if the ID exists during block render (backend) and re-generate it if it is missing. And during frontend render it would be nice to have this too checked – It is really annoying now for me to go throughout tens of pages and checking each FAQ.
I did for example to cover all block on frontend:
/**
* Fix the issue with plugin, some time plugin fails to add the id attribute to the FAQ block.
*
* @param string $block_content
* @param array $block
* @param \WP_Block $instance
* @return string
*/
function filter_faq_meow_block_items_id( string $block_content, array $block, \WP_Block $instance ) {
$random_id = \substr( \md5( \uniqid() ), 0, 8 );
$block_content = \str_replace(
[ 'id=""', '<input ', '<input id="" ', '<input id= ', '<input id=' ],
[ 'id="' . $random_id . '"', '<input id="' . $random_id . '" ', '<input id="' . $random_id . '" ', '<input id="' . $random_id . '" ', '<input id="' . $random_id . '" ' ],
$block_content
);
$block_content = \str_replace(
[ 'for=""', '<label ', '<label for="" ', '<label for= ', '<label for='],
[ 'for="' . $random_id . '"', '<label for="' . $random_id . '" ', '<label for="' . $random_id . '" ', '<label for="' . $random_id . '" ', '<label for="' . $random_id . '" ' ],
$block_content
);
return $block_content;
}
\add_filter( 'render_block_meowapps/faq', __NAMESPACE__ . '\\filter_faq_meow_block_items_id', 10, 3 );
]]>
Hi, I used to have plugin version 1.0.4, but I tested 1.0.7 to 1.0.8.
I did upgrade to 1.0.8. All current FAQ become broken and I had to click “Recovery block”.
This is due to schema that is added since 1.0.8.
To avoid this you should apply https://developer.www.ads-software.com/block-editor/reference-guides/block-api/block-deprecation/ to avoid this kind of issue, or maybe make some function that fix the blocks in background – like add note in dashboard that says “Blocks require update, make backup and click here to proceed” and make cron that upgrade all blocks.
After clicking recovery the schema is added but it is incorrect.
My block from version before:
<!-- wp:meowapps/faq -->
<div class="wp-block-meowapps-faq meow-faq-block"><input type="checkbox" id="" name=""/><label class="meow-faq-question" for="">I hele klassen</label><div class="meow-tab-answer"><div class="meow-tab-content"><strong>Nerv?s kropp <br/></strong><br/><strong>Du trenger:</strong> Tack-it (l?rertyggis) eller teip, <em>Vedlegg 4: N?r jeg er nerv?s</em>, tusj/ fargeblyanter og et stort papirark som legges p? gulvet. <br/><br/><strong>Fremgangsm?te:</strong> Fortell gruppen at dere skal lage et stort bilde sammen. Be et barn legge seg ned p? papiret og tegn rundt kroppen hans eller hennes. Gruppen skal sette fast kortene p? tegningen av kroppen n?r dere diskuterer kortene. Bruk gjerne andre idéer som kommer fra gruppen.<br/><br/>P? denne m?ten kan det utvalgte barnet forholde seg direkte til tegningen, og hele klassen lager et produkt sammen. Det utveksles mange idéer. </div></div></div>
<!-- /wp:meowapps/faq -->
Block After upgrade:
<!-- wp:meowapps/faq -->
<div class="wp-block-meowapps-faq meow-faq-block"><input type="checkbox" id="f0r8k3xb7" name="f0r8k3xb7"/><label class="meow-faq-question" for="f0r8k3xb7">Eplesalat</label><div class="meow-tab-answer"><div class="meow-tab-content">Historiene i <em>Eples venner </em>har seks hovedpersoner: Eple, Tig, Leela, Sandy, Jill og Tommy.<br/><br/>Be barna sette seg i en sirkel og gi hvert barn etter tur navnet p? én av hovedpersonene.<br/><br/>N?r du sier ?Tig?, bytter alle barna som heter Tig plass – og s? videre med de andre navnene.<br/><br/>Barn setter stor pris p? denne leken. Den er ogs? veldig nyttig for ? bryte opp grupper av barn som alltid sitter sammen.</div></div><script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [{
"@type": "Question",
"name": "Eplesalat",
"acceptedAnswer": {
"@type": "Answer",
"text": "Historiene i ,[object Object],har seks hovedpersoner: Eple, Tig, Leela, Sandy, Jill og Tommy.,[object Object],[object Object],Be barna sette seg i en sirkel og gi hvert barn etter tur navnet p? én av hovedpersonene.,[object Object],[object Object],N?r du sier ?Tig?, bytter alle barna som heter Tig plass – og s? videre med de andre navnene.,[object Object],[object Object],Barn setter stor pris p? denne leken. Den er ogs? veldig nyttig for ? bryte opp grupper av barn som alltid sitter sammen."
}
}]
}</script></div>
<!-- /wp:meowapps/faq -->
Notice the [object Object]
. Some time there is more some time less of those.
I’d recommend in next upgrade to add some code that fix existing schema issue if – remove the object object from existing schemas if that was generated.
]]>Google tells me that my FAQ field is double. I do understand, because I have to use a FAQ block for each question. It seems I can not add an other question without adding a new FAQ block. I am doing something wrong or is this the way it is?
]]>Concerning your note
I am not sure if it’s currently a bug in Gutenberg: this block requires an input in the generated HTML but for some reason, Gutenberg removes it from the DOM while saving. This issue only happens for author/editors, but not for admins (which is even more weird).
This is actually not that weird. On single sites, administrators can use unfiltered HTML but not other roles. Note that only super-admins are allowed to this on multisite.
Maybe this will point you in the right direction: https://wordpress.stackexchange.com/questions/327949/custom-gutenberg-block-and-unfiltered-html-capability
—
Unfortunately, the resulting HTML is also not accessible. Perhaps you can take some pointers from this article: https://alvaromontoro.com/blog/68017/creating-a-css-only-toggle-switch
I like that the plugin is lightweight, and the block is simple. But because of the above-mentioned limitations, I won’t use it.
]]>Hello. Google Error Console alerted me about FAQ structured data issues detected. I have a page with multiple Question/Answer Gutenberg blocks. Is there a way to fix the multiple FAQPage fields?
]]>This plugin would be pretty much perfect if it included FAQ schema markup in the blocks. Here’s an article from Google that explains why FAQ markup is necessary for search engines to recognise (and reward) good FAQs.
FAQ schema markup doesn’t have to be for a whole page. It can be for individual blocks. Here’s an example of the block-specific code approach from the Google page:
{"@type": "Question", "name": "Whom to contact?",
"acceptedAnswer": {
"@type": "Answer", "text": "You can contact the apprenticeship office through our official phone hotline above, or with the web-form below. We generally respond to written requests within 7-10 days." }
}
If you need help testing and troubleshooting this feature request I’d be more than happy to help.
https://developers.google.com/search/docs/appearance/structured-data/faqpage
]]>I installed your plugin to replace the deprecated Genesis Simple FAQ although the latter still worked. I was able to copy and paste the questions and answers except the first one. I edited that block in HTML and entered the ordered list code. When I switched back to visual edit mode, only the first list item was kept and everything else was concatenated at the end of that.
I tried saving the page while in the HTML edit mode and it kept the list. Could there be a simpler way of entering a list
By the way, as you will see, the FAQ list is duplicated with the old one below the new one, the cat’s meow! I wanted to keep them both until my update of the site continues on this staging site.
]]>hey guys ??
I’ve got a problem: whenever my clients edit the faq blocks, they break. clicking on them doesn’t work anymore, so they are useless. my clients have the user role “author”. does it have anything to do with that?
I’ve to set up the block again from the scratch to make it work again, and that shouldn’t be the case. I’m looking forward to hearing from you ??
greetings
Diana
]]>I used this on this page;
https://piedmontcardiovascular.com/patient-information/faqs/
and I like the gradient background for the questions.
I’m redesigning the site on a new theme, installed this but now the questions are a flat black.
https://piedmontcardiovascular.com/temp/patient-information/faqs/
I can’t find any way to change to the gradient. I copied the css onto my stylesheet, but it’s being overridden. In the page editor for either page, there’s no control over the FAQ block.
]]>hey!
I wanted to ask you if you could be so kind and help me with the gap between each single faq block, you can see what I mean on the following screenshots ??
screenshot1
screenshot2
the gap is really big and I want to make it smaller (so it’s about 15px or something like that). I tried to fix it with some custom css but unfortunately there are strange input fields (which aren’t displayed but are there, see screenshot3) – each with a different ID – so I can’t just simple write some css to get them hidden, because everytime my customer makes a new faq block, there is this gap again (and he is not able to fix this issue). so I’m quite desperate how to fix this globally…
screenshot3
thanks for helping! ??
greetings
Diana
Hey,
Is there any way to link to a particular question with the answer opened up?
]]>Hello,
was it already updated for WordPress 5.3? It isn’t working anymore, because it is not responding / showing the answer.
Best regards,
pwie
]]>Hello,
Thanks for FAQ blocks. It’s a simple lightweight solution. I’d like to see it have Google Structured Data/Schema Markup integration. Is that something you can do with it?
]]>Hello,
if another user (not an admin) is changing text in the answer and saves the changes, the FAQ blocks break. If there is one change in one FAQ block, it breaks all other FAQ blocks on the page. Why does this happen?
In revisions I can see that it removes all specific input ids. If I make changes (as admin), everything is working as expected.
Thanks in advance
]]>Hi Jordy.
This block does not work with the Gutenberg plugin. The reason is that you’re using the RichText component from window.wp.editor instead of window.wp.blockEditor. In WP5 it’s location in both .editor with a deprecated warning as of 5.3 and .blockEditor but by using the Gutenberg plugin it’s only location in .blockEditor.
We hope you can do a quick release with this fix as we really like using this block on our client projects.
Regards,
Stian, Dekode
It would be great to be able to add extra formatting to the answers like lists etc.
]]>I made one faq block and then duplicated it to make my other ones. after saving and viewing the page, trying to open any of the faqs always only opened the first one. in the inspector it showed they all had the same id and name attributes. i went back in to edit the page, edited each of the blocks again, saved, viewed the page and it worked as expected.
]]>Hi, i was testing out your plugin and noticed this issue. if you copy and paste text from a sketch file or a word document it will include style rules for the element in the pasted text before the content in either the question or answer section.
]]>Was using with WP 4.9, and then upgraded to the newly released 5.0, which gave this exception:
Fatal error: Uncaught Error: Call to undefined function gutenberg_get_jed_locale_data() in /var/www/betatest/wordpress/wp-content/plugins/faq-block/faq-block.php:55 Stack trace: #0 /var/www/betatest/wordpress/wp-includes/class-wp-hook.php(286): MeowApps_FAQ_Block->admin_init('') #1 /var/www/betatest/wordpress/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /var/www/betatest/wordpress/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /var/www/betatest/wordpress/wp-admin/admin.php(156): do_action('admin_init') #4 /var/www/betatest/wordpress/wp-admin/plugins.php(10): require_once('/var/www/betate...') #5 {main} thrown in /var/www/betatest/wordpress/wp-content/plugins/faq-block/faq-block.php on line 55
I had to remove the plugin by hand (rm) to allow me to access again to WP. Trying to install it from scratch also fails.
]]>