Hi @theguitarlesson,
Why don’t you just use a plugin like Custom Post Type UI plugin? It’s easy.
I hope it will help.
Kind regards,
Herman 🙂
Thanks, but that just registers the custom post type.
My custom template is complicated, I need to be able to display a lot of variables using PHP, so it doesn’t help.
Hi @theguitarlesson,
What if you use Hooks to display those variables on your CPT? Please refer to this page.
I hope it helps.
Kind regards,
Herman 🙂
Hi,
That’s what I tried to do, but it didn’t seem to work. This is the reason I tried getting help from the makers of Astra.
Hi @theguitarlesson,
Sorry for the delay.
I noticed that you opened a ticket for a similar query thru our Support Portal. If this thread is the same as the one on the ticket, please continue the communication using the ticket. Otherwise, please reply to this thread.
Please let us know.
Kind regards,
Herman 🙂
Support from Astra Pro helped me figure this out, here is the code:
// Remove Astra content from Custom Post Type page
add_action('wp', 'remove_astra_content_from_cpt');
function remove_astra_content_from_cpt(){
if ( is_singular( 'NAMEOFYOURCUSTOMPOSTTYPEGOESHERE' ) ) {
remove_action( 'astra_entry_content_single', 'astra_entry_content_single_template');
}
}
function add_cpt_content() {
// bail if this current post type is different.
if ( is_singular( 'NAMEOFYOURCUSTOMPOSTTYPEGOESHERE' ) ) {
?>
<!-- Your custom HTML markup here -->
<p>My custom theme HTML at astra_entry_content_before</p>
<?php
}
}
add_action( 'astra_entry_top', 'add_cpt_content' );
`
Hope this helps somebody 🙂