Archived topic
Using Shortcode in Search Results Loop
3 replies · Started by Christian on December 15, 2022
Dear support forum :-)
I am currently trying to build the search results with a Loop template and dynamic blocks. This is working fine so far. But I want to generate a custom breadcrumb path for each result (loop item). I tried to insert a custom shortcode but I am not able to fetch the post id (global $post returns same array every time the shortcode is called). Another idea is to manipulate "List of terms" dynamic data, but I cannot find the right filter to hook into this.
I would appreciate some help!
Thanks in advance and best regards,
Christian
Hi there,
the way the blocks are rendered won't allow the shortcode to get the object ID.
Instead of using a shortcode use the render_block filter to swap out the static contents of a block.
See here for an example of that:
https://generatepress.com/forums/topic/formatting-acf-date-output-in-post-query/#post-2457681
Great hint, will give it a try! Thanks, David!
You're welcome