get post publish date outside the loop in wordpress

To get post publish date outside the loop in wordpress use the following code.

$all_posts = get_posts(array('numberposts'=>-1, 'post_status'=> 'publish')); //Get all published posts
foreach ($all_posts as $single_post){
    echo get_the_time('Y-m-d', $single_post->ID); //The date is on Y-m-d format
    echo '<br />' ;

Hope this code will help you.

Get Template Path in WordPress Child Themes

To get the child theme path use this code on your child theme

<?php echo dirname( get_bloginfo('stylesheet_url') ); ?>

Journal – Free wordpress Bootstrap theme

I have lunched a new free WordPress Bootstrap theme.
This theme is packed with features :

  • Using Bootstrap framework
  • Theme option panel
  • Video support
  • Widget ready
  • Language support
  • And best of all free to use

Here is the live theme demo

Download from Github

PHP Warning: Missing argument 2 for wpdb::prepare() after upgrading to WordPress 3.5

Are you getting wpdb::prepare() error on after upgrading to WordPress 3.5 ?

Don’t worry your website is not broken.

WordPress is just working you that your theme or plugin is not prepare to fight with hacker.

And your website is possibly expose for SQL injection vulnerability.

So how to stop this error and fix your website ?

A quick solve is to put

@ini_set('display_errors', 0);

on your WordPress wp-config.php. (Note: Hiding errors on production sites is good practice anyway.)

Now Here’s how $wpdb->prepare() is supposed to work:

$wpdb->prepare( "SELECT * FROM table WHERE ID = %d AND name = %s", $id, $name );

See how $id and %s is passed as a argument. This makes sure your query is safe.

And may be your code are like this format

$wpdb->prepare( "SELECT COUNT(*) FROM table" );

So you are getting error message

Please comment if you have any question

Load jquery library from google CDN in wordpress

Add this code on wordpress theme functions.php to deregister the urgent jquery and load jquery library from google.

function load_cdn_jquery() {

    // only use this method is we're not in wp-admin
    if (!is_admin()) {

        // deregister the original version of jQuery

        // discover the correct protocol to use
        if($_SERVER['HTTPS']=='on') {

        // register the Google CDN version
        wp_register_script('jquery', $protocol.'//', false, '1.5.2');

        // add it back into the queue


add_action('template_redirect', 'load_cdn_jquery');

Removing extra p and line breaks from shortcodes in WordPress

Some time shortcodes add some some extra <p> and <br /> after of before post.This is happend because of the wpautop filter.

You can easily prevent this by changing the execution priority of wpautop filter.

Simply use this code on your theme functions.php

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);

New Code to Display Latest Tweets

[highlight]The code below no longer works as-is with the Twitter API update to 1.1 as of 2013-06-11.Here’s a PHP way to interact with the new Twitter API.[/highlight]

Twitter recently deprecated the code that we using to display latest tweets

<div id="twitter_update_list"></div>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

So the above code will not work any more.
We have to use this updated code to get latest tweet

<div id="twitter_update_list"></div>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

Remove Width and Height Attributes from wordpress content area

When you upload images using WordPress image uploader and insert it into your post/page, it will include the image width and height attribute in the tag.if you want to remove this automatic image width and height attribute from image, you can add this code to you functions.php

add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;


Also there is a css solution for you also

/* Images */
.entry-content img,
.comment-content img,
.widget img {
    max-width: 97.5%; /* Fluid images for posts, comments, and widgets */
img[class*="wp-image-"] {
    height: auto; /* Make sure images with WordPress-added height and width >attributes are scaled correctly */
img.size-full {
    max-width: 97.5%;
    width: auto; /* Prevent stretching of full-size images with height and >>width attributes in IE8 */


Easy Press : Free WordPress Theme

Easy Press is a free WordPress theme.You can easily use this theme for your WordPress blog or for your news website.I make this theme using my BLANK RESPONSIVE HTML5 WORDPRESS THEME.

It came with following features:
[list style=”check”]

  • HTML5 and CSS3
  • Theme Option Panel
  • Custom Widgets
  • Dynamic Footer widget area
  • Have full control on Home page, post and page
  • SEO optimized


[button link=”” color=”#b00″ size=”1″ style=”1″ dark=”1″ square=”1″] Live Demo [/button]

version 1: [wpdm_file id=2]

Version 2: [wpdm_file id=3]

Add visitor browser name in the body class function

You can easily detect browser using this function and add visitor browser name in the body class function .

Put this on your theme functions.php

function myfunction_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';
	elseif($is_opera) $classes[] = 'opera';
	elseif($is_NS4) $classes[] = 'ns4';
	elseif($is_safari) $classes[] = 'safari';
	elseif($is_chrome) $classes[] = 'chrome';
	elseif($is_IE) $classes[] = 'ie';
	else $classes[] = 'unknown_browser';

	if($is_iphone) $classes[] = 'iphone';
	return $classes;

The sample output may like this

<body class="home logged-in ie">