Archived topic
Inserting Hook into the Query Loop block
9 replies · Started by Erika on July 18, 2022
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
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...
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?
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
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.
Glad to hear its working :)
Using the dynamic data works great.
Question: how do I turn the text link into an external link icon?
Hi Ron,
You can add an icon and "remove the text". Relevant article: https://docs.generateblocks.com/article/icon-overview/
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.
I see. Glad you found a workaround.
If you'll need further assistance regarding this, kindly open a new topic.