[Resolved] Inserting Hook into the Query Loop block

Home Forums Support [Resolved] Inserting Hook into the Query Loop block

Home Forums Support Inserting Hook into the Query Loop block

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2285887
    Erika

    Hi there,

    is there a way to insert a hook (just like a subtitle) into the post template of the Query Loop block?

    It should look like in the link, the element is created as a block element –> type:hook, inserted under the entry title. However, I´d like to have it in the Query Loop block unter the entry title.

    Thanks, Erika

    #2286084
    David
    Staff
    Customer Support

    Hi there,

    you can try creating a hook within a shortcode with this PHP Snippet:

    function db_hook_inside_shortcode($atts, $content = null) {
          ob_start();
          do_action('db_inside_post_loop');
          return ob_get_clean();
    }
    add_shortcode('hooky_shortcode', 'db_hook_inside_shortcode');

    This creates a shortcode called: [hooky_shortcode] which you can add inside a Headline block.
    That then creates a hook called: db_inside_post_loop

    I haven’t tested this…

    #2286349
    Erika

    Sorry, I did not fully get it.
    I created a snippet in Code snippet with the above code.
    Then I go to a) Elements > the block-element I created –> insert short code? or b) I go to the Query Loop block and insert the short code there?
    How does this function get the custom field content from the post?

    #2286363
    David
    Staff
    Customer Support

    How does this function get the custom field content from the post?

    How id this added ?

    If its just a straight forward custom field, then you don’t need a hook or any of the above.

    1. Add a Headline Block.
    2. Enable its Dynamic Data options
    3. Set these options
    Data Source: Post
    Content Source: Post Meta
    Post meta field: enter the name of your custom field

    #2286404
    Erika

    I´ll go crazy. It was exactly what I was doing originally, but I forgot to press ENTER after entering the name of the custom field. So let´s keep it that simple.

    #2287135
    David
    Staff
    Customer Support

    Glad to hear its working 🙂

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