How To Display Results In WordPress Search
Using the following snippet you will be able to display the number of results in WordPress Search.
1 |
<h2 class="pagetitle">Search Results</h2> |
Now, simply replace it with to:
1 2 3 4 5 6 7 8 9 |
<h2 class="pagetitle">Search Results for <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?></h2> |
Snippet Source/Credit: ProBlogDesign
Changing The Post Updated Message Itself In WordPress
Using the following snippet, you will be able to change the post updated message in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
add_filter('post_updated_messages', 'listing_updated_messages'); function listing_updated_messages( $messages ) { $messages['listing'] = array( 0 => '', // Unused. Messages start at index 1. 1 => sprintf( __('Listing updated. <a href="%s">View Listing</a>'), esc_url( get_permalink($post_ID) ) ), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Listing updated.'), /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf( __('Listing restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => sprintf( __('Listing published. <a href="%s">View Listing</a>'), esc_url( get_permalink($post_ID) ) ), 7 => __('Listing saved.'), 8 => sprintf( __('Listing submitted. <a target="_blank" href="%s">Preview Listing</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 9 => sprintf( __('Listing scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Listing</a>'), // translators: Publish box date format, see http://php.net/date date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 10 => sprintf( __('Listing draft updated. <a target="_blank" href="%s">Preview Listing</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), ); return $messages; } |
Snippet Source/Credit: Snipplr
How To Define A Minimum Word Count Per Post In WordPress
The following snippet will let you define a minimum word count per post in WordPress.
1 2 3 4 5 6 7 8 |
function minWord($content){ global $post; $num = 100; //set this to the minimum number of words $content = $post->post_content; if (str_word_count($content) < $num) wp_die( __('Error: your post is below the minimum word count.') ); } add_action('publish_post', 'minWord'); |
Snippet Source/Credit: Pippin Williamson
How To Use Gravatars In Your Script
With the use of following snippet below, you will be able to use Gravatars in your script.
1 2 3 4 5 6 7 8 |
<?php function show_my_gravatar($email, $size, $default, $rating) { $params = '?gravatar_id='.md5($email).'&default='.$default.'&size='.$size.'&rating='.$rating; $output = '<img src="http://www.gravatar.com/avatar.php'.$params.'" width="'.$size.'px" height="'.$size.'px" />'; echo $output; } ?> |
Snippet Source/Credit: apphp.com
How To Disable Plugin Updates In WordPress
The snippet below will let you disable all the plugins updates in WordPress.
1 2 3 4 |
<?php remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); ?> |
Snippet Source/Credit: WP-Snippets.com
How To Replace ‘Howdy, Admin’ In WordPress With Something Else
The following snippet will let you replace “Howdy, Admin” in WordPress.
1 2 3 4 5 6 7 8 9 |
function replace_howdy( $wp_admin_bar ) { $my_account=$wp_admin_bar->get_node('my-account'); $newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title ); $wp_admin_bar->add_node( array( 'id' => 'my-account', 'title' => $newtitle, ) ); } add_filter( 'admin_bar_menu', 'replace_howdy',25 ); |
Snippet Source/Credit: Snipplr