Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View baczoni's full-sized avatar

Aron Baczoni baczoni

View GitHub Profile
@baczoni
baczoni / gist:2479916
Created April 24, 2012 14:05
Wordpress: Change excerpt length
//Change Excerpt Length -- Add to functions.php
function new_excerpt_length($length) {
return 35; //Change word count
}
add_filter('excerpt_length', 'new_excerpt_length');
@baczoni
baczoni / gist:2479976
Created April 24, 2012 14:08
Wordpress: Remove nofollow from comments
// remove nofollow from comments
function xwp_dofollow($str) {
$str = preg_replace(
'~<a ([^>]*)\s*(["|\']{1}\w*)\s*nofollow([^>]*)>~U',
'<a ${1}${2}${3}>', $str);
return str_replace(array(' rel=""', " rel=''"), '', $str);
}
remove_filter('pre_comment_content', 'wp_rel_nofollow');
add_filter ('get_comment_author_link', 'xwp_dofollow');
add_filter ('post_comments_link', 'xwp_dofollow');
@baczoni
baczoni / gist:2480003
Created April 24, 2012 14:11
Wordpress: Add favicon to your site
// add a favicon to your
function blog_favicon() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
}
add_action('wp_head', 'blog_favicon');
@baczoni
baczoni / gist:2480022
Created April 24, 2012 14:13
Wordpress: Remove version info from head and feeds
<?php
// remove version info from head and feeds
function complete_version_removal() {
return '';
}
add_filter('the_generator', 'complete_version_removal');
@baczoni
baczoni / gist:2480462
Created April 24, 2012 15:12
Wordpress: Display user info
<?php
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID; // You can set $user_id to any users, but this gets the current users ID.
$user_twitter = get_user_meta( $user_id, 'twitter', true);
echo $user_twitter;
?>
@baczoni
baczoni / gist:2480471
Created April 24, 2012 15:13
Wordpress: Add/Remove contact info fields
<?php
function new_contactmethods( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter'; // Add Twitter
$contactmethods['facebook'] = 'Facebook'; // Add Facebook
unset($contactmethods['yim']); // Remove YIM
unset($contactmethods['aim']); // Remove AIM
unset($contactmethods['jabber']); // Remove Jabber
return $contactmethods;
}
@baczoni
baczoni / gist:2480899
Created April 24, 2012 15:48
Wordpress: Separate comments from trackbacks
<?php
// Find:
foreach ($comments as $comment) :
// Comments are displayed here
endforeach;
?>
<?php
// And replace with:
?>
@baczoni
baczoni / gist:2480723
Created April 24, 2012 15:34
Wordpress: Disable dashboard widgets
// http://codex.wordpress.org/Dashboard_Widgets_API
<?php
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
@baczoni
baczoni / gist:2480515
Created April 24, 2012 15:17
Wordpress: Custom login logo
<?php
function custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image:url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; }
</style>';
}
add_action('login_head', 'custom_login_logo');
?>
@baczoni
baczoni / gist:2480964
Created April 24, 2012 15:55
Wordpress: Enable excerpt for pages
<?php
function my_init() {
add_post_type_support('page', array('excerpt'));
}
add_action('init', 'my_init');
?>