Advertisement
fauzanjeg

Change Logo for Spesific Category Page || 90Radio Category Page for Example

Nov 7th, 2021
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. /* Change Logo for Spesific Category Page || 90Radio 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 */
  13.         $term = get_queried_object(); /* Get Current Category Data */
  14.         $list_category = array( '90radio', 'another-example-category-slug', 'lifestyle' ); /* List Slug of Category */
  15.         if ( is_category() && in_array( $term->slug, $list_category ) ) { /* If is Category Page and Current Category Slug in List Category */
  16.             /* Link Logo URL */
  17.             $logo             = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  18.             $logo_retina      = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  19.             $alt              = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  20.             $logo_dark        = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  21.             $logo_retina_dark = 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Service_mark.svg/1280px-Service_mark.svg.png';
  22.         }
  23.         /* END Custom Change */
  24.  
  25.         return JNews\Image\Image::generate_image_retina( $logo, $logo_retina, $alt, $echo, $logo_dark, $logo_retina_dark );
  26.     } else {
  27.         $logo_text = get_theme_mod( 'jnews_header_logo_text', 'Logo' );
  28.  
  29.         return jnews_generate_logo_text( $logo_text, $echo );
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement