Having shortcodes inside shortcodes may or may not be a problem. Relevanssi runs the content through
do_shortcode(), which should expand all shortcodes inside the content, even nested shortcodes.
The relevanssi_post_content_after_shortcodes filter hook filters the post content right after Relevanssi runs
do_shortcode(). What does the content look like at that point?
Here’s what the the content looks like at the point of relevanssi_post_content_after_shortcodes:
(I output this to the using the error_log function. I’m redacting some content to keep the project private.)
[22-Jun-2022 05:09:23] WARNING: child 4377 said into stderr: "NOTICE: PHP message: <p>With a mission to foster.</p>"
[22-Jun-2022 05:09:23] WARNING: child 4377 said into stderr: "<p>Embracing the collaboration. </p> <h2>Want to Learn more?</h2> "
There are two Divi Code modules each with a Pods shortcodes between the last </p> and the <h2> which aren’t showing up. But this is where the plot thickens because there’s also a hardcoded <h4> in those code modules which isn’t part of the Pods shortcode and that’s also not showing up.
Here’s what the code inside the Divi Code module looks like:
[pods name="person" where="rel_committee_chair_of.post_title = 'Some Committee'" template="List of People - Committee Chairs"][/pods]
Seeing that the <h4>Committee Chair</h4> text didn’t show up in the indexing, it looks like the problem is actually with the Divi Code module and not the processing of the Pods shortcodes.
In fact I confirmed this by putting the Pods shortcode inside a Divi Text module, and when I did that, Relevanssi indexed it correctly.
So whatever Divi is doing with their Code module is preventing Relevanssi from seeing content in there. For my purposes, my problem is essentially solved. I don’t need to use the Code module to insert shortcodes; I can just change all of the shortcodes to use a Text module instead. But this is probably something you will want to look into to see if there is a way for Relevanssi to index content inside of the Divi Code module.
Thanks for your help in sorting this out. I wouldn’t have figured it out without the clues from the relevanssi_post_content_after_shortcodes function.
Is the Divi Code module shortcode
[et_pb_code]? Relevanssi removes the
[et_pb_code] shortcode and its contents in the indexing on purpose. I don’t remember what the exact reason is; it may be Divi encodes the code shortcode contents or something like that.
You can change the Relevanssi behaviour using the
relevanssi_page_builder_shortcodes filter hook, to keep the
[et_pb_code] shortcode contents intact – but this may or may not help, I’m not sure. Using a different module in Divi is a guaranteed fix for this.
Yes, the Divi Code module is et_pb_code. According to the Divi site, the Code module is intended for how I’m using it: “a blank canvas that allows you to add code to your page, such as plugin shortcodes or static HTML” (https://www.elegantthemes.com/documentation/divi/code/)
Does Relevanssi remove the Gutenberg Custom HTML block?
I’ll give the relevanssi_page_builder_shortcodes a try and see if that works.
I’m not sure what’s going on in the et_pb_code, but you have good reason to remove it from the index. After using the relevanssi_page_builder_shortcodes filter to allow all et_pb_code content through, the indexing failed every time.
I’ll go back to the initial plan of using the et_pb_text module for any shortcode content that I need indexed.
Thanks again for your help with this!