Site logo

[Support request] Using Shortcode in Search Results Loop

Home Forums Support [Support request] Using Shortcode in Search Results Loop

Home Forums Support Using Shortcode in Search Results Loop

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2463085
    Christian

    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

    #2463101
    David
    Staff
    Customer Support

    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

    #2463147
    Christian

    Great hint, will give it a try! Thanks, David!

    #2463813
    David
    Staff
    Customer Support

    You’re welcome

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