Custom post template?
-
Hi,
I created a custom post template for a custom post type (CPT). I named it after my CPT e.g. single-cpt.php and copied the the content of single.php. It works so far.
Since Astra is doing the whole layout of the post in astra_content_loop() – which is defined in other files – I’m adding my custom HTML via the astra_entry_content_before hook, see:
get_header(); ?> <?php add_action( 'astra_entry_content_before', 'add_cpt_content' ); function add_cpt_content() { ?> <p>My custom theme HTML</p> <?php } ?> <?php if ( astra_page_layout() == 'left-sidebar' ) : ?> <?php get_sidebar(); ?> <?php endif ?> <div id="primary" <?php astra_primary_class(); ?>> <?php astra_primary_content_top(); ?> <?php astra_content_loop(); ?> <?php astra_primary_content_bottom(); ?> </div> <?php if ( astra_page_layout() == 'right-sidebar' ) : ?> <?php get_sidebar(); ?> <?php endif ?> <?php get_footer(); ?>
Is there a better way to create custom post templates where I can edit what happens in astra_content_loop()?
The workaround with the hook is somewhat an ugly hack.
- The topic ‘Custom post template?’ is closed to new replies.