Site logo

Archived topic

Hook not displaying properly on custom post type

5 replies · Started by Kevin on April 5, 2022

Viewing posts 1–6 of 6

I've created a custom post type with a content template that pulls in the title, featured image, and content dynamically. For this custom post type, I've created a custom hook for social media sharing buttons. In most parts of the custom post type, I'm able to display these social buttons with no issues and predictably. However, when I try to use the hooks to generate after entry title, before entry content, etc. It will not display where it should.

If I change the hook location to just regular posts it displays exactly where it should. Is there an extra step I'm supposed to take to get it to display after my title with custom post types? The hook works and displays perfectly otherwise, I just cant get it to display after my title, or before my content.

Here is a link to the custom post type in question and the social media sharing buttons displaying properly at the bottom of the page (generate_after_do_template_part)

Hook Issue

However, when I try to use the hooks to generate after entry title, before entry content, etc. It will not display where it should.

When you say you are using a content template for the CPT, do you mean a block element - content template?

If so, there will be NO more entry title/entry content in your CPT as they're not defined in the content template.

Ah, I do mean a block element - content template so that explains why it won't display on that custom post type. Is there a way to do a custom hook that would make it display before the content in this custom post type?

I love how lightweight this hook is and I'd love to have these buttons display above the content.

Is it possible to turn your current PHP code into a shortcode?

Then you can add the shortcode using a shortcode block to the block element.

Fantastic thought, thank you, Ying!

No problem :)

This archived topic is closed to new replies.