Explor Wordpress

Author: Wordpresscore Page 2 of 11

WordPress Show a Post Date and Modified Date

Sometimes six months after you write a post you decide to update it with some new information. This simple snippet will add a modified date to your posts in the event that you make a change sometime after the initial publication date.

Posted on <?php the_time('F jS, Y') ?>
          $u_time = get_the_time('U');
          $u_modified_time = get_the_modified_time('U');

      if ($u_modified_time != $u_time) {
                echo "and last modified on ";
                the_modified_time('F jS, Y');
                echo ". ";

WordPress Remove the Private/Protected From Your Post Titles

In case you ever publish posts that are private, you’ll notice that the title is prefaced by an unsightly reminder. You can add the code below to your functions file and everything will look good again.

function the_title_trim($title) {

$title = attribute_escape($title);

$findthese = array(

$replacewith = array(
'', // What to replace "Protected:" with
'' // What to replace "Private:" with

$title = preg_replace($findthese, $replacewith, $title);
return $title;
add_filter('the_title', 'the_title_trim');

WordPress Using the Current Year in Your Posts

Do you ever wish you could insert the current year in some of your posts via a simple shortcode?
Add the snippet below to your functions.php file and you’ll be partying like it’s [year].

function year_shortcode() {
$year = date('Y');
return $year;
add_shortcode('year', 'year_shortcode');

WordPress Redirect New Registered Users to a Specific Page

If you require a new user to register on your WordPress site, you might want to redirect them to a specific page upon successful completion. Maybe you want to provide them with some important information or specific download.

function wps_registration_redirect(){
return home_url( '/finished/' );
add_filter( 'registration_redirect', 'wps_registration_redirect' );

WordPress get Tiny URL

Everyone likes tiny, little URLS. Use this snippet to get them:

function get_tiny_url( $url ) 
$tiny_url = file_get_contents( "http://tinyurl.com/api-create.php?url=".$url ); 
return $tiny_url;

WordPress add Paypal Donate Button

Essential for non-profits and charities.

function donate_shortcode( $atts, $content = null) { 
global $post;extract(shortcode_atts(array( 
'account' => 'your-paypal-email-address',
'for' => $post->post_title,
'onHover' => '',
), $atts));</p> 
<p&gt;if(empty($content)) $content='Make A Donation'; 
return '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;<span id="IL_AD3" class="IL_AD">business</span>='.$account.'&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;item_name=Donation for '.$for.'" title="'.$onHover.'">'.$content.'</a>'; 
add_shortcode('donate', 'donate_shortcode'); 

WordPress Show Tag Cloud

Does what it says – show your tag cloud.

<?php wp_tag_cloud(array( 
'smallest' => 10,      // size of least used tag 
'largest' => 18,       // size of most used tag 
'unit' => 'px',        // unit for sizing 
'orderby' => 'name',   // alphabetical
'order' => 'ASC',      // starting at A 
'exclude' => 6         // ID of tag to exclude from list 
)); ?> 

WordPress Gravatar for Comments

Easily include your gravatar in your comments

$email = $comment->comment_author_email;
$default = "http://DOMAIN.COM/gravatar.jpg"; // enter a link to your default avatar
$size = 80; // size in px, this covers width and height
$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5($email) . "&amp;default=" . urlencode($default) . "&amp;size=" . $size;
<img src="<?=$grav_url ?>" height="<?=$size ?>" width="<?=$size ?>" alt="gravatar" class="gravatar" title="<?php comment_author();?>"/>

WordPress Show List of Recently Created Blogs

Show off all of your latest blogs. Insert into your functions:

/*Fetch an array of $number_blogs most recently created blogs
**@number_blogs :The number of most recently created blogs you want to show. 
function get_recent_blogs($number_blogs=5) 
global $wpdb; 
/*fetch blog_id,domain,path from wp_blogs table ,where the blog is not spam,deleted or archived order by the date and time of registration */ 
$query="select blog_id,domain,path from $blog_table where public='1' and archived='0' and spam='0' and deleted='0' order by registered desc limit 0,$number_blogs"; 
return $recent_blogs; 

Use the following to get its output:

<ul class="recent-blogs"> 
<?php $recent_blogs=get_recent_blogs(5); 
<span style="white-space: pre;"> </span&gt;foreach($recent_blogs as $recent_blog): 
<span style="white-space: pre;"> </span>$blog_url=""; 
<span style="white-space: pre;"> </span&gt;if( defined( "VHOST" ) &amp;&amp; constant( "VHOST" ) == 'yes' ) 
<span style="white-space: pre;"> </span>$blog_url="http://".$recent_blog->domain.$recent_blog->path; 
<span style="white-space: pre;"> </span&gt;else
<span style="white-space: pre;"> </span>$blog_url="http://".$recent_blog->domain.$recent_blog->path; 
<span style="white-space: pre;"> </span>$blog_name=get_blog_option($recent_blog->blog_id,"blogname"); 
<span style="white-space: pre;"> </span>?> 
<h3><a href="<?php echo $blog_url;?>"> </a></h3> 
<span><?php echo $blog_name?></span> 
<?php endforeach;?> 

WordPress Detect User from Yahoo

Freak your visitors out by saying “Hello! Yahoo User.”

<?php if (strpos($_SERVER[HTTP_REFERER], "yahoo") ) { 
echo "Hello Yahoo! User!"; 
} ?>

Page 2 of 11

Powered by WordPress & Theme by Anders Norén