Skip to content

Instantly share code, notes, and snippets.

@rushijagani
Created October 19, 2018 11:07
Show Gist options
  • Save rushijagani/aa2303d9cb68b2ce8a933581f4e70a01 to your computer and use it in GitHub Desktop.
Save rushijagani/aa2303d9cb68b2ce8a933581f4e70a01 to your computer and use it in GitHub Desktop.
Override Custom Post Type template
<?php
add_action( 'astra_content_loop', 'custom_post_type_loop_callback' );
function custom_post_type_loop_callback(){
if( "movies" == get_post_type() ) {
remove_action( 'astra_template_parts_content', array( Astra_Loop::get_instance(), 'template_parts_default' ) );
remove_action( 'astra_template_parts_content', array( Astra_Loop::get_instance(), 'template_parts_post' ) );
if ( is_singular( "movies" ) ) {
add_filter( 'astra_post_link', '__return_false' );
}
?>
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php
while ( have_posts() ) :
the_post();
// Custom Post Type template
get_template_part( 'template-parts/content', 'movies' );
?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</main><!-- #main -->
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment