add your own Logo
Your Own Logo //hook the administrative header output add_action('admin_head', 'my_custom_logo'); function my_custom_logo() { echo ' <style type="text/css"> ...
Search Engine Visitors
Display Content to Search Engine Visitors functions: <?php function scratch99_fromasearchengine() { $ref = $_SERVER['HTTP_REFERER']; $SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.'); foreach($SE as $source) { if(strpos($ref, $source) ...
Author List
Display an Author List with Avatars function contributors() { global $wpdb; $authors ...
Required Plugin Is Active
Check If Required Plugin Is Active $plugins = get_option('active_plugins'); $required_plugin = 'debug_queries/debug_queries.php'; $debug_queries_on = FALSE; if ( in_array( $required_plugin , $plugins ) ) { $debug_queries_on = TRUE; // Example for ...
Page-based Navigation
Page-based Navigation < ul id="nav"> <?php // Checks if a Page is being used as front page if('page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ...
User Contact Info
extend the User Contact Info <?php function my_new_contactmethods( $contactmethods ) { // Add Twitter $contactmethods['twitter'] = 'Twitter'; //add Facebook $contactmethods['facebook'] = 'Facebook'; ...
commented posts with thumbnails
commented posts with thumbnails <?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <?php $justanimage = get_post_meta($post->ID, 'Image', true); if ($justanimage) { ?> ID, "Image", true); ?>" ...
number of tweets
Display the number of tweets for each page or post function tweetCount($url) { $content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url); $element = new SimpleXmlElement($content); $tweets = $element->story->url_count; echo $tweets." tweets!"; } <?php tweetCount($post->permalink); ?>
dashboard footer
change the dashboard footer text function remove_footer_admin () { echo "Your own text"; } add_filter('admin_footer_text', 'remove_footer_admin');
ads on old posts
display ads on old posts only function is_old_post($post_id=null){ $days = 15; global $wp_query; if(is_single() || is_page()) { ...
display RSS feeds
Fetch and display RSS feeds <?php if(function_exists('fetch_feed')) { include_once(ABSPATH.WPINC.'/feed.php'); $feed = fetch_feed('http://feeds.feedburner.com/catswhoblog'); $limit = $feed->get_item_quantity(7); // specify number of items $items = $feed->get_items(0, $limit); // create an array of items } if ...
detect mobile visitor
detect mobile visitors include('mobile_device_detect.php'); $mobile = mobile_device_detect(); if ($mobile==true) { header( 'Location: http://your-website.com/?theme=Your_Mobile_Theme' ) ; }
CSS with a custom field
Embed CSS in your posts with a custom field <?php if (is_single()) { $css = get_post_meta($post->ID, 'css', true); if (!empty($css)) { ?> <style type="text/css"> <?php echo ...
Remove /category/ from url
Remove /category/ from your WordPress url RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]
enlight searched text
enlight searched text in search results echo $title; replaced with <?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">', $title); ?>
privates pages in navigation
privates pages in navigation menus < ul> <?php wp_list_pages('depth=1&title_li=0&sort_column=menu_order'); if(current_user_can('read_private_pages')) : ?> < li> < a href="<?php echo get_permalink(10); ?>">For Authors only< /a> < /li> <?php endif; ?> < /ul>
Get parent page/post
Get parent page/post title <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?>
Remove widget
Remove widget areas <?php add_filter( 'sidebars_widgets', 'disable_all_widgets' ); function disable_all_widgets( $sidebars_widgets ) { if ( is_home() ) $sidebars_widgets = array( false ); return $sidebars_widgets; } ...
detect browser
detect the visitor browser <?php add_filter('body_class','browser_body_class'); function browser_body_class($classes) { global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; if($is_lynx) $classes[] = 'lynx'; elseif($is_gecko) $classes[] = 'gecko'; ...
title overwrite
title overwrite <?php $title = get_post_meta($post->ID, "custom-title", true); if ($title != "") { echo "<h1>".$title."</h1>"; } else { ?> <h1><?php the_title(); ?></h1> <?php } ?>
insert author bio
Automatically insert author bio on each post function get_author_bio ($content=''){ global $post; $post_author_name=get_the_author_meta("display_name"); $post_author_description=get_the_author_meta("description"); $html="<div class='clearfix' id='about_author'>\n"; $html.="\n"; $html.="<div class='author_text'>\n"; $html.="<h4>Author: <span>".$post_author_name."</span></h4>\n"; $html.= $post_author_description."\n"; $html.="</div>\n"; $html.="<div class='clear'></div>\n"; ...
body_class function
Extend the body_class function add_filter('body_class','top_level_parent_id_body_class'); function top_level_parent_id_body_class($classes) { global $wpdb, $post; if (is_page()) { if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } $classes[] = 'top-level-parent-pageid-' . $parent; ...
thumbs related
Display all thumbs related to a specific page on a media page in WordPress function wallthumb($id=false,$beforelist='< ul class="gallerythumb">',$afterlist='< /ul>',$beforeitem='< li>',$afteritem='< /li>'){ ...
show post attachments
show WordPress post attachments $args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { echo apply_filters('the_title', $attachment->post_title); ...