[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 10 posts - 1 through 10 (of 10 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 🙂

    #2558063
    Ron

    Using the dynamic data works great.
    Question: how do I turn the text link into an external link icon?

    #2558115
    Fernando
    Customer Support

    Hi Ron,

    You can add an icon and “remove the text”. Relevant article: https://docs.generateblocks.com/article/icon-overview/

    #2558161
    Ron

    I tried that and it hides the text in the editor, but not in the cpt archive page.
    I did a workaround and used a button w/ icon and used Hide text. Same issue, so I used css to hide the button link text.

    #2558175
    Fernando
    Customer Support

    I see. Glad you found a workaround.

    If you’ll need further assistance regarding this, kindly open a new topic.

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