Advertisement
fauzanjeg

Change Logo for Spesific Page || Category Page for Example

Nov 5th, 2021
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. /* Change Logo for Spesific Page || Category Page for Example */
  2. function jnews_generate_header_logo( $echo = true ) {
  3.     if ( get_theme_mod( 'jnews_header_logo_type', 'image' ) === 'image' ) {
  4.         $logo        = get_theme_mod( 'jnews_header_logo', get_parent_theme_file_uri( 'assets/img/logo.png' ) );
  5.         $logo_retina = get_theme_mod( 'jnews_header_logo_retina', get_parent_theme_file_uri( 'assets/img/logo@2x.png' ) );
  6.         $alt         = get_theme_mod( 'jnews_header_logo_alt', get_bloginfo( 'name' ) );
  7.  
  8.         /*Dark logo*/
  9.         $logo_dark        = get_theme_mod( 'jnews_header_logo_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode.png' ) );
  10.         $logo_retina_dark = get_theme_mod( 'jnews_header_logo_retina_darkmode', get_parent_theme_file_uri( 'assets/img/logo_darkmode@2x.png' ) );
  11.  
  12.         /* START Custom Change || If is Category Page */
  13.         if ( is_category() ) {
  14.             $logo             = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  15.             $logo_retina      = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  16.             $alt              = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  17.             $logo_dark        = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  18.             $logo_retina_dark = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  19.         }
  20.         /* END Custom Change */
  21.  
  22.         return JNews\Image\Image::generate_image_retina( $logo, $logo_retina, $alt, $echo, $logo_dark, $logo_retina_dark );
  23.     } else {
  24.         $logo_text = get_theme_mod( 'jnews_header_logo_text', 'Logo' );
  25.  
  26.         return jnews_generate_logo_text( $logo_text, $echo );
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement