Remove Admin (User #1) from User list

function your_pre_user_query($user_search) { $user = wp_get_current_user(); if ($user->ID!=1) { global $wpdb; $user_search->query_where = str_replace(‘WHERE 1=1’, “WHERE 1=1 AND {$wpdb->users}.ID<>1”,$user_search->query_where); } } add_action(‘pre_user_query’,’your_pre_user_query’);

Read More

Easy to use & embed iFrame Shortcode

function GenerateIframe( $atts ) { extract( shortcode_atts( array( ‘href’ => ‘http://the-url’, ‘height’ => ‘550px’, ‘width’ => ‘600px’, ), $atts ) ); return ‘<iframe src=”‘.$href.'” width=”‘.$width.'” height=”‘.$height.'”> <p>Your Browser does not support Iframes.</p></iframe>’; } add_shortcode(‘iframe’, ‘GenerateIframe’); // how to use: [iframe href=”http://www.exmaple.com” height=”480″ width=”640″]

Read More

Make WordPress Editor Allow iFrames

// make TinyMCE allow iframes add_filter(‘tiny_mce_before_init’, create_function( ‘$a’, ‘$a[“extended_valid_elements”] = “iframe[id|class|title|style|align| frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]”; return $a;’) );

Read More

Auto Include Google Analytics Code

Tested on: WordPress 3.1 RC3 I’ve been using this script on all of my sites since WordPress 2.3.0 … it just adds the standard Google tracking scripts to the footer. // Add Google Analytics Tracking Code function add_google_analytics() { ?> <script type=”text/javascript”> var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”); document.write(unescape(“%3Cscript src='” + […]

Read More

Display Specific Content only for logged in users

Tested on: WordPress 3.0.1 function content_only4logged_in($content) { // ALL LOGGED IN USERS if ( is_user_logged_in() && !is_null($content) && !is_feed() ) { return $content; } else { $content = wp_html_excerpt( $content, 80 ); $content .= ‘ …’; $content .= __( ‘Sorry, more of this content is only available for logged users.’, FB_TEXTDOMAIN ); return $content; } […]

Read More

Custom excerpt length

function excerpt($num) { $limit = $num+1; $excerpt = explode(‘ ‘, get_the_excerpt(), $limit); array_pop($excerpt); $excerpt = implode(” “,$excerpt).”… (<a href='” .get_permalink($post->ID) .” ‘>Read more</a>)”; echo $excerpt; } Limit the length of the displayed excerpt by writing in the theme: excerpt(’20’); Example: <?php excerpt(’22’); ?> This will limit the excerpt to 22 characters. The excerpt will be […]

Read More

Custom Dashboard CSS

/* Change WordPress dashboard CSS */ function custom_admin_styles() { echo ‘<style type=”text/css”>#wphead{background:#069}</style>’; } add_action(‘admin_head’, ‘custom_admin_styles’); function custom_admin_styles() {     echo ‘<style type=”text/css”>#wp-admin-bar-new-content{display:none;}</style>’;     echo ‘<style type=”text/css”>#wp-admin-bar-comments{display:none;}</style>’;     echo ‘<style type=”text/css”>#wp-admin-bar-wp-logo{display:none;}</style>’;     echo ‘<style type=”text/css”>#screen-meta-links{display:none;}</style>’; } You can add any changes to the css between the tags.

Read More

Custom Admin Footer

function custom_admin_footer() { echo ‘Welcome to my blog! No More Documentation Links!’; } add_filter(‘admin_footer_text’, ‘custom_admin_footer’);

Read More

Custom Favicon WP-Admin

function admin_favicon() { echo ‘<link rel=”shortcut icon” type=”image/x-icon” href=”‘ . get_bloginfo(‘template_directory’) . ‘/images/favicon.ico” />’; } add_action( ‘admin_head’, ‘admin_favicon’ );  

Read More