arie_cristianD

change header logo on certain category page

Jul 31st, 2025
1,149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1.  
  2. add_filter( 'theme_mod_jnews_header_logo', 'j_change_header_logo' );
  3. add_filter( 'theme_mod_jnews_header_logo_retina', 'j_change_header_logo_retina' );
  4.  
  5. /**
  6.  * Change Retina logo URL.
  7.  *
  8.  * @param string $logo Logo URL.
  9.  * @return string
  10.  */
  11. function j_change_header_logo_retina( $logo ) {
  12.     if ( j_is_selected_category() ) {
  13.         $logo = 'http://localhost.local/wp-content/uploads/2025/07/[email protected]'; /* change with your retina logo URL */
  14.     }
  15.     return $logo;
  16. }
  17.  
  18. /**
  19.  * Change logo URL.
  20.  *
  21.  * @param string $logo Logo URL.
  22.  * @return string
  23.  */
  24. function j_change_header_logo( $logo ) {
  25.     if ( j_is_selected_category() ) {
  26.         $logo = 'http://localhost.local/wp-content/uploads/2025/07/footer_logo.png'; /* change with your logo URL */
  27.     }
  28.     return $logo;
  29. }
  30.  
  31.  
  32. /**
  33.  * Check if in selected category page.
  34.  *
  35.  * @return bool
  36.  */
  37. function j_is_selected_category() {
  38.     if ( is_category() ) {
  39.         $category = get_queried_object();
  40.  
  41.         if ( $category && isset( $category->slug ) ) {
  42.             $slug = $category->slug;
  43.  
  44.             /* Selected category list. */
  45.             $selected_category = array(
  46.                 'jnews_demo_gaming',
  47.                 'jnews_demo_gear',
  48.             );
  49.             if ( in_array( $slug, $selected_category ) ) {
  50.                 return true;
  51.             }
  52.         }
  53.     }
  54.     return false;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment