Skip to content

Instantly share code, notes, and snippets.

@shizhua
shizhua / testimonial.js
Created August 25, 2015 14:23
Add a Fancy Testimonial to your wordpress website
jQuery(document).ready(function($) {
var e = $(".mts-testimonial"),
t = $(".testimonials-authors li"),
f = $(".mts-testimonial:first"),
l = $(".testimonials-authors li:first");
f.css({
opacity: 1
});
l.addClass("active-testimonial");
t.hover(function() {
<?php
add_filter( 'manage_posts_columns', 'ws_cutom_columns_head', 20 );
add_action( 'manage_posts_custom_column', 'ws_cutom_columns_content', 10, 2 );
function ws_cutom_columns_head( $columns ) {
$columns['ws_post_id'] = 'ID';
return $columns;
@shizhua
shizhua / add_action.php
Created August 24, 2015 14:13
insert ad codes after first, second or nth post. http://wpsites.org/?p=10364/
<?php
function insert_between_posts( $post ) {
global $wp_query;
// Check if we're in the right template
if ( ! is_home() )
return;
// Check if we're in the main loop
if ( $wp_query->post != $post )
@shizhua
shizhua / remove-comment-url.php
Created August 24, 2015 13:57
Remove URL field from comment form in wordpress
<?php
/**
* Remove URL field from comment form in wordpress
* by Leo
* URL: http://wpsites.org/?p=10448
*/
add_filter('comment_form_default_fields', 'website_remove_url');
function website_remove_url( $fields ) {
if ( isset($fields['url']) ) {
unset( $fields['url'] );
@shizhua
shizhua / hide-admin-bar.php
Created August 24, 2015 13:54
Hide the admin bar in wordpress
<?php
add_filter( 'show_admin_bar', '__return_false' );
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
?>
@shizhua
shizhua / excerpt-character-count.php
Created August 24, 2015 13:53
Add a Character Counter to Excerpt box
<?php
/**
* Add a Character Counter to Excerpt box
* URL: http://wpsites.org/?p=10503
*/
function excerpt_count_js(){
echo '<script>jQuery(document).ready(function(){
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:5px;right:80px;color:#666;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"excerpt_counter\" readonly=\"\" style=\"background:#fff;\"> <small>character(s). (128 Characters MAX)</small></div>");
jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length);
<?php if( function_exists( 'pt_time_to_read' ) ) { echo pt_time_to_read( 'Time to read: ', ' Minutes' ); } ?>