Last active
December 4, 2016 07:32
-
-
Save aldolat/632de15f5aaf11917610e3db5d779868 to your computer and use it in GitHub Desktop.
Remove title attribute and shorten title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this function to your functions.php file or to your functions plugin. | |
function posts_in_sidebar_hacks() { | |
wp_enqueue_script( 'pis-add-hacks', get_template_directory_uri() . '/js/pis-hacks.js', array( 'jquery' ), false, true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'posts_in_sidebar_hacks' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(){ | |
// Remove the title attribute from all links with "pis-thumbnail-link" class. | |
jQuery('a.pis-thumbnail-link').removeAttr("title"); | |
// Shorten all links with "pis-title-link" class to 9 characters if they are longer than 10 characters. | |
jQuery('a.pis-title-link').each(function(){ | |
var str = jQuery(this).text(); | |
str = str.trim(str); | |
if (str.length > 10) { | |
jQuery(this).text(str.substr(0, 9)); | |
jQuery(this).append('…'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment