-
DavidBirkman
Hello,
I was looking how to create Element after post content. In the end of the blog post I would like to add custom: tags, category, …etc.
For header, you can create element, but how to add element after post content blog article?
Please help.
-
George
Hi,
You can do this with a Block Element:
- Go to Appearance > Elements > Add New Element
- Choose Block as the element type
- Set element type as Hook and select an appropriate hook (e.g., “after_content”)
- Set the Display Rules to target your single posts (e.g., Post → All Posts)
- Build your content inside the element using GenerateBlocks, including any dynamic tags for tags, categories, etc.
If “after_content” doesn’t give you the exact placement you want, you can switch to a different hook, eg: “after_entry_content”.
-
DavidBirkman
This is great George. Resolved.
I don’t want to open new topic, so I will ask here:
I created in Elements > HOOK and instead of HOOK_NAME I made Custom Hook Name “list_model_units”. I made Custom hook name because I want to insert into middle of the post (somewhere I want).
Now I want in the middle of post/page insert that hook name “list_model_units”. How do a do that?
Any help page of guide.
-
George
Hi,
Add this small snippet via a code snippets plugin.
add_shortcode( 'list_model_units', function() { ob_start(); do_action( 'list_model_units' ); return ob_get_clean(); });Then in your post or page content, just insert:
[list_model_units]Wherever you place that shortcode, your Hook Element will render at that spot.
Make sure your Hook Element’s Display Rules are set to Entire Site (or at least include every location where you plan to use the shortcode). The Element only listens for the hook on pages where its display rules apply — so if it’s restricted to a single post type, the shortcode won’t output anything elsewhere.
Also, avoid slashes in custom hook names (e.g.
my/custom/hook) — GP sanitizes those out. Stick with underscores or hyphens. -
DavidBirkman
I did what you wrote, and it doesn’t work.
Have a look screenshot:
Screenshot gallery -
Alvind
Hi David,
It looks like the shortcode isn’t being rendered because the shortcode string itself is appearing in the output. That usually means there’s an issue with the PHP snippet that registers the shortcode.
May I know which plugin or method you’re using to add the snippet?
Alternatively, try using another supported method for adding PHP:
https://docs.generatepress.com/article/adding-php/ -
DavidBirkman
I’m using PHP Code Snippet:
Screenshot PHP Snippet -
Alvind
Try setting the Placement Methods to Shortcode (Manual) and the Tracking Name to list_model_units.
Lastly, in the PHP code field, add just this:
ob_start(); do_action( 'list_model_units' ); return ob_get_clean(); -
DavidBirkman
No, this didn’t work. The problem was plugin “PHP Code Snippets”. I tried “Code Snippets” and it works fine now.
add_shortcode( 'list_model_units', function() { ob_start(); do_action( 'list_model_units' ); return ob_get_clean(); }); -
Alvind
Glad to hear that!
- You must be logged in to reply to this topic.