Advertisement
arie_cristianD

change post template in custom post type

Nov 17th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. add_filter( 'jnews_single_post_template', 'change_glossary_template', 99, 2 );
  2. add_filter( 'theme_mod_jnews_single_blog_custom', 'change_glossary_custom_template', 99 );
  3.  
  4. function change_glossary_template( $template, $post_id ) {
  5.     if ( 'glossary' === get_post_type( $post_id ) ) {
  6.         $template = 'custom';
  7.     }
  8.     return $template;
  9. }
  10.  
  11.  
  12. function change_glossary_custom_template( $default ) {
  13.     if ( 'glossary' === get_post_type( get_the_ID() ) ) {
  14.         $default = 4670; /* change this with your custom post templlate ID */
  15.     }
  16.     return $default;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement