• kadaj

    (@aldabogskie)


    Hi can I change the image rating properly based on posts category? Here’s my current setup using jQuery but it is messed up:

    Currently there are three post category which are “Game”, “Movie” and “Comic”
    https://gamersloveconnection.com/imoo/

    My code below:

    jQuery('#game .post-ratings img').each(function(){
    			var img_this = jQuery(this).attr('src');
    			img_this = img_this.split("/");
    
    			if(img_this[img_this.length-1] == 'rating_on.gif'){
    				jQuery(this).attr('src', '<?php echo home_url(); ?>/wp-content/themes/kleo-child/images/Controller.PNG');
    			}
    		});
    
    		jQuery('#movie .post-ratings img').each(function(){
    			var img_this = jQuery(this).attr('src');
    			img_this = img_this.split("/");
    
    			if(img_this[img_this.length-1] == 'rating_on.gif'){
    				jQuery(this).attr('src', '<?php echo home_url(); ?>/wp-content/themes/kleo-child/images/Film.PNG');
    			}
    		});
    
    		jQuery('#comic .post-ratings img').each(function(){
    			var img_this = jQuery(this).attr('src');
    			img_this = img_this.split("/");
    
    			if(img_this[img_this.length-1] == 'rating_on.gif'){
    				jQuery(this).attr('src', '<?php echo home_url(); ?>/wp-content/themes/kleo-child/images/comic.jpg');
    			}
    		});
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Rating images replacement’ is closed to new replies.