Skip to content

Instantly share code, notes, and snippets.

View smonteverdi's full-sized avatar

Sean Monteverdi smonteverdi

View GitHub Profile
@smonteverdi
smonteverdi / gist:2731661
Created May 19, 2012 17:41
WordPress: Add Widget to Dashboard
// Add a widget in WordPress Dashboard
function wpc_dashboard_widget_function() {
// Entering the text between the quotes
echo "<ul>
<li>Release Date: March 2012</li>
<li>Author: Aurelien Denis.</li>
<li>Hosting provider: my own server</li>
</ul>";
}
function wpc_add_dashboard_widgets() {
@smonteverdi
smonteverdi / gist:2731658
Created May 19, 2012 17:40
WordPress: Hiding Dashboard Widgets
add_action('wp_dashboard_setup', 'wpc_dashboard_widgets');
function wpc_dashboard_widgets() {
global $wp_meta_boxes;
// Today widget
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
// Last comments
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
// Incoming links
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
// Plugins
@smonteverdi
smonteverdi / gist:2433276
Created April 21, 2012 02:12
WordPress: Show Custom Post Type Inside/Outside of loop
function is_post_type($type){
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
return false;
}
@smonteverdi
smonteverdi / gist:2422720
Created April 19, 2012 18:11
WordPress: Customize Excerpt Length
add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($length) {
return 20; }
@smonteverdi
smonteverdi / gist:2378858
Created April 13, 2012 18:09
WordPress: Display child pages in template
<?php
global $wp_query;
if( empty($wp_query->post->post_parent) ) {
$parent = $wp_query->post->ID;
} else {
$parent = $wp_query->post->post_parent;
} ?>
<?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
<ul class="nav nav-list">
@smonteverdi
smonteverdi / gist:2378216
Created April 13, 2012 16:37
WordPress: Breadcrumbs
<?php
if (function_exists('register_sidebar')) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
@smonteverdi
smonteverdi / gist:2344892
Created April 9, 2012 17:30
WordPress: Update admin password with a query
UPDATE `wp_users` SET `user_pass` = MD5( 'new_password_here' ) WHERE `wp_users`.`user_login` = "admin_username";
@smonteverdi
smonteverdi / gist:2320807
Created April 6, 2012 15:31
WordPress: Default Styles
/* =WordPress Core
-------------------------------------------------------------- */
.alignnone {
margin: 5px 20px 20px 0;
}
.aligncenter, div.aligncenter {
display:block;
margin: 5px auto 5px auto;
}
@smonteverdi
smonteverdi / gist:2288580
Created April 3, 2012 01:27
WordPress: Adding Custom Fields
function fb_add_custom_user_profile_fields( $user ) {
?>
<h3><?php _e('Extra Profile Information', 'your_textdomain'); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="address"><?php _e('Address', 'your_textdomain'); ?>
</label></th>
<td>
<input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
@smonteverdi
smonteverdi / theme-options.php
Created March 24, 2012 14:44
WordPress: Options Page Starter
// Load up the theme options. Put this line in your functions.php file
require_once ( get_template_directory() . '/theme-options.php' );
<?php
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
/**