Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Change logo on each page of University Hub theme [closed]

I would add a filter to the body class in your functions.php file. This will add a class based on the page/post/cpt slug:

PHP:

/**
 *
 * Add Page/Post Body Class Slug
 *
 * post-slug-for-post
 * page-slug-for-page
 *
 *
 */
function yourprefix_page_slug_body_class( $classes ) {
    global $post;
    if ( isset( $post ) ) {
        $classes[] = $post->post_type . '-' . $post->post_name;
    }
    return $classes;
}
add_filter( 'body_class', 'yourprefix_page_slug_body_class' );

Then I would use jQuery to swap the src based on the body class. You will need to change the path variable and possibly the parent class where the logo img is located (the example uses .site-branding).

jQuery

 ( function( window, $, undefined ) {

     'use strict';


     $( document ).ready( function(  ) {


        /* ==== change logo based on body class ===

        // default logo and path
        var path="http://yourdomain.com/wp-content/uploads/",
            logo  = 'logo-1.png'; // this is the default


        // logo 2 conditional change var value
        if ( $( 'body' ).is( '.page-such-and-such' ) ) {
            logo = 'logo-2.png';
        }

        // logo 3 conditional change var value
        if ( $( 'body' ).is( '.post-such-and-thing' ) ) {
            logo = 'logo-3.png';
        }

        // return the logo src
        $( '.site-branding img' ).attr( 'src', path + logo );


        // end swapping logo


    } ); //* end ready


} )( this, jQuery );

Create a document with your code editor name it swapping-logo.js (or whatever) and enqueue it with jQuery as a dep. The instructions on adding js to your theme are everywhere.

Related Posts:

  1. Getting rid of unused css directives [closed]
  2. How do I copy my Parent Templates to my Child Templates?
  3. How to load parent theme style.css?
  4. Child Style.css not overriding parent theme style located in assets/css/main.css
  5. How does a Child Theme works?
  6. Creating new templates in child themes breaks layout
  7. Port existing Bootstrap site to WordPress?
  8. Child theme’s stylesheet cannot load [closed]
  9. What’s the default order used by WordPress to load CSS files?
  10. The requested theme does not exist. Stylesheet is missing – error after changing style.css name to my-styles.css in wp child theme?
  11. Why submenu item’s background color is not changing by css?
  12. Strange Theme Error – parent style occasionally showing though child theme
  13. Child theme after CSS modification
  14. Custom Theme Additonal CSS “” are transformed to “&gt” and “&lt”
  15. Opinions and recommendations on the best barebones base theme [closed]
  16. How to add CSS class to custom logo?
  17. Customizing a WordPress theme without changing it?
  18. how to add version of style.css in wordpress
  19. How to move the sidebar in TwentyFifteen to the right?
  20. Override parent theme translation on child theme
  21. Starter Theme vs Parent Theme? Pros and cons
  22. How to set thumbnail image for a (child) theme
  23. How can I version the main CSS file?
  24. Do Child-Themes automatically load the Translation from the Parent-Theme?
  25. Difference between stylesheet_directory and template_directory
  26. How to override the “inc” folder (or any folder) in a theme using child theme?
  27. Multiple image logo for theme
  28. How to set two different themes on one WordPress? (Desktop vs. Mobile)
  29. Jquery in Child Theme
  30. Removing Shortcodes from Child Theme
  31. I’m trying to add an image in my CSS
  32. How to use scss in wordpress theme?
  33. How to automatically highlight syntax of code in a post?
  34. How to add the main style.css to my index.php?
  35. Edit theme wp_head
  36. The style.css stylesheet doesn’t contain a valid theme header
  37. Are custom inner theme folders in any way overridable by child themes?
  38. How to avoid loading style.css twice in child-theme?
  39. Remove action within a class in a parent theme from the child theme
  40. CSS in child theme not overriding the parent theme [closed]
  41. Child Theme Not Overriding Parent Theme
  42. Override parent theme translation on child theme
  43. Exclude stylesheet from admin
  44. hfeed CSS class in Twentyeleven Theme
  45. Child-theme breaks site
  46. Change Theme from Plugin based on query_vars
  47. get_header(‘header2’) not working properly in child themes
  48. Want to create Child theme, but already edited Parent theme css files and some php files
  49. Is it possible to use child theme of child them?
  50. Theme information in style.css being corrupted
  51. Can I create multiple instances of the BuddyPress Activity Stream with separate themes? [closed]
  52. How do you create a custom WPTouch theme?
  53. How to start learning CSS and theme development?
  54. Can’t Install Child Theme “The parent theme is missing. Please install the “Default” parent theme.”
  55. Can I rename a theme’s folder and still receive updates?
  56. Child theme not visible
  57. Overwriting templates in child theme and performance
  58. How do I apply my CSS to a theme page?
  59. Themes—Child Themes
  60. how to remove padding from left and right side? [closed]
  61. 404 Error while accessing the font files
  62. Child theme not using parent theme css/styles/formatting?
  63. Does theme update also update a child theme zip
  64. What is the major difference between child theme and normal theme
  65. Should a child theme share the same theme options row as the parent, or should it have it’s own options row?
  66. How to add an RSS logo to my blogs header?
  67. How to create child theme of already active and customized theme
  68. Inject widgets from one sidebar into another with PHP
  69. Where all are child themes recorded when they are created in WordPress
  70. I have some doubts regarding how to implement child theme
  71. none of my css is working in my child theme
  72. X-Axis of Site is Messed Up Because it is in Hebrew
  73. How can I use a logo in the header?
  74. How do I get rid of or change the footer in my child theme?
  75. Style the archives/category sidebar widget via theme
  76. How to find out if page_for_posts is showing (in order to style menu item)
  77. Custom CSS doesn’t work in edit mode
  78. Remove transparancy in Sydney theme’s headerimage
  79. How to change only one javascript function in wordpress child theme?
  80. How can I add class to every quote element?
  81. Mobile issue – website isn’t properly detecting screen size [closed]
  82. Edited Child Theme’s “header.php” but it doesn’t appear to change the file
  83. Updating my free theme delete all my changes [closed]
  84. Twenty fifteen theme – change responsive menu condition
  85. Switching to a child theme
  86. CSS Start Fresh option on; main.css still being loaded [closed]
  87. Getting 503 on various files
  88. Can’t resize logo in responsive theme?
  89. Do not show one specific widget on one specific page
  90. How to style the post previews/links without it affecting the main posts?
  91. Different logo on homepage
  92. How can we hide the parent’s theme url at the child themes details on a multisite?
  93. Is it possible to create child themes using the WordPress Dashboard?
  94. Finding and disabling ‘rogue’ stylesheet from header: Source Sans Pro
  95. Cannot apply custom css to IE in the theme
  96. how do i in ignore/disable/delete a javascript call from parent in child theme?
  97. Can I create a child theme from a premium theme without losing my posts and page etc that I already have?
  98. Need to edit themes HTML code
  99. Enqueue custom css file on specific page
  100. Plugin and themes are adding the same stylesheets
Categories themes Tags child-theme, css, logo, themes
Could a higher number of registered image sizes affect performance?
Disable comments from showing up public for Custom Post Type

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress