arie_cristianD

use Custom Post Template for Image Post Format

Jul 24th, 2025
1,403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. add_filter( 'theme_mod_jnews_single_blog_template', 'change_jnews_single_post_template' );
  2. add_filter( 'theme_mod_jnews_single_blog_custom', 'change_jnews_custom_single_post_template' );
  3.  
  4. /**
  5.  * Change JNews single post tempalte with custom
  6.  *
  7.  * @param string $template Template name.
  8.  * @return string
  9.  */
  10. function change_jnews_single_post_template( $template ) {
  11.     if ( 'image' === get_post_format() ) {
  12.         return 'custom';
  13.     }
  14.     return $template;
  15. }
  16.  
  17. /**
  18.  * Change JNews custom post template id.
  19.  *
  20.  * @param int|string $template Single Post Template ID.
  21.  * @return integer|string
  22.  */
  23. function change_jnews_custom_single_post_template( $template ) {
  24.     if ( 'image' === get_post_format() ) {
  25.         return 248; /* Change this with your Custom Single Post Template ID  */
  26.     }
  27.     return $template;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment