How to customize Comment Count Text in wordpress

Some people asked me about changing the default wordpress comment template and comment count text. If you are wordpress developer than it is easy.

customize Comment Count Text in wordpress

You can customize the text for displaying comments number or count inside loop. This is just a simple template edit however it is extremely useful if you are creating a theme that is not a traditional theme or you wanted to inject a little bit of personality into the site.

You just need to copy and paste following code into comments.php file.

Using  following code you can change:

<?php
    echo get_comments_number_text( "No thoughts, yet", "One Thought only", "% thoughts");
?>

wordpress-comment-count

There are some useful articles about wordpress comments customization:

change author url without wordpress plugin

wp user want to use other url for admin user. You can easily change using wordpress hook. you can change author url in wordpress without wordpress plugin. using code you can do this. wordpress developer can use this code.

change author url without wordpress plugin

There is default username in wordpress. admin is default username in wordpress but many times user want to use other wordpress user url for admin user. You can easily do this by using following wordpress hook.

You just need to place following code in functions.php file which is your theme folder.

add_action('init', 'change_wordpress_author_url');
function change_wordpress_author_url() {
global $wp_rewrite;
$author_slug = 'new_author_url';
$wp_rewrite->author_base = $author_slug;
}

You need to choose your author url. Just replace the “new_author_url” word and put in functions.php file.

change author url without wordpress plugin
how to change the author url in wordpress without wordpress plugin

how to get post data outside loop in wordpress

WordPress hack, In this wordpress tutorial we given code and shown, how to get post data outside loop in wordpress. In wordpress theme you can get post data.

how to get post data outside loop in wordpress

Outside the loop you can get the a post data. you just need to copy paste following code in your theme file.

<?php
global $post;

$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );

$myposts = get_posts( $args );

foreach( $myposts as $post ) : setup_postdata($post); ?>
 <li>
 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
 </li>
<?php endforeach; ?>
how to get post data outside loop in wordpress
how to get post data outside loop in wordpress

How to create custom shortcode for wordpress site

There are many wordpress plugins which using the shortcode. But you easily create custom shortcode for wordpress site. there is no need of external plugin.

custom shortcode for wordpress

Since Version 2.5 WordPress support so called Shortcodes. They have been introduced for creating macros to be use in a posts content. Many people looking for how to create the shortcode in wordpress using theme. It is very easy to build shortcode in wordpress. I given very simple code sample for creating the custom shortcode.

For more information visit following page.

For creating the custom shortcodes you need add following method in functions.php file which is located in your theme folder.


function myshortcode(){
 return '<img src="http://images.purabtech.in/How-to-make-empty-the-wordpress-trash-automatically.png">';
}
add_shortcode('myshortcode', 'myshortcode');

custom shortcode for wordpress
custom shortcode for wordpress

you can change the return text or shortcode name aslo.

Remove theme editor from WordPress setting menu

Many wordpress developers want to remove the theme editor option from wordpress appearance settings menu. Due to security reason removing theme editor from wordpress admin section is really great idea.

In this tutorial I given simple steps to remove theme editor option from your wordpress admin section.

You just need to copy and paste following code into your functions.php file. That will hide the theme editor menu from settings page.
Using following code you can easily remove editor.

function wpapi_remove_editor_menu() {
  remove_action('admin_menu', '_add_themes_utility_last', 101);
}

global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //Specify admin name here
    add_action('admin_menu', 'wpapi_remove_editor_menu', 1);
} 
Remove theme editor from WordPress setting menu
Remove theme editor from WordPress setting menu

10+ wordpress lightbox plugins useful for slideshow

Jquery lightbox is mostly used for slideshows in web based project. In wordpress that is most favorite. Here I collected some nice wordpress lightbox plugins.

wordpress lightbox plugins

Lightbox Plus ColorBox

Lightbox Plus ColorBox,wordpress lightbox plugins
wordpress lightbox plugins

Lightbox Plus ColorBox implements ColorBox as a lightbox image overlay tool for WordPress. ColorBox was created by Jack Moore and is licensed under the MIT License. Lightbox Plus ColorBox for WordPress implements ColorBox as a lightbox image overlay tool for WordPress. ColorBox was created by Jack Moore and is licensed under the MIT License. Lightbox Plus ColorBox permits users to view larger versions of images without having to leave the current page. Lightbox is able to add a lightbox to WordPress gallery images, display simple slide shows, video, forms and external content in overlays. The use of the dark or light background, which dims the page over which the image has been overlaid, also serves to highlight the image or video being viewed. Lightbox Plus ColorBox captures the image title for display in the overlay.

Simple Lightbox

Simple Lightbox,wordpress lightbox plugins
wordpress lightbox plugins

The next generation of Simple Lightbox is here and ready for brave beta testers. Sign up for SLB 2.0 beta now while there’s still space available!

Simple Lightbox is a very simple and highly customizable lightbox that is easy to add to your WordPress website. It also supports skins, so it can be fully integrated with your site’s theme.

WP Lightbox 2

WP Lightbox 2,wordpress lightbox plugins
WP Lightbox 2,wordpress lightbox plugins

From 2.1, the default view changed to Colorbox due to the license regulation by the plugin directory. This plugin used to add the lightbox (overlay) effect to the current page images on your WordPress blog. Used to overlay images on the current page. Extension of wp-jquery-lightbox.

Just install and sit back. This plugin enable image overlay lighbox effect for all the post images in your wordpress plugin. No configuration required.

WP jQuery Lightbox

WP jQuery Lightbox,wordpress lightbox plugins
WP jQuery Lightbox,wordpress lightbox plugins

This plugin lets you keep the awesome Lightbox 2-functionality, but sheds the bulk of the Prototype Framework and Scriptaculous Effects Library.
Warren Krewenki ported Lightbox to jQuery and this plugin is mostly a wrapper to his work: providing localization support, an admin panel for configuration, (optional) auto-boxing of your image links and support for WordPress galleries, including media library titles and captions.

Lightbox Gallery

Lightbox Gallery,wordpress lightbox plugins
Lightbox Gallery,wordpress lightbox plugins

the default view changed to Colorbox due to the license regulation by the plugin directory. If you would prefer the prior Lightbox to Colorbox, you need to get the script from the setting page.

Clifton’s Lightbox

Clifton's Lightbox,wordpress lightbox plugins
Clifton’s Lightbox,wordpress lightbox plugins

Clifton’s Lightbox implements a lightbox subscription form overlay. Features a title, list, call-to-action, and image or YouTube video. Users can embed their subscription form into the lightbox and use the call-to-action area to encourage new subscribers.
Clifton’s Lightbox Demo
http://cliftonhatfield.com/cliftons-lightbox/

Lightbox Pop

Lightbox Pop,wordpress lightbox plugins
Lightbox Pop,wordpress lightbox plugins

This plugin allows you to create a lightbox popup with custom contents. You can customize the popup display by configuring various settings such as position settings (height, width, top,left), display logic settings (time delay after page load, number of pages to browse, lightbox repeat interval) and style settings(z-index, overlay opacity, color, border etc). You can use the plugin to display any type of contents such as special promotions, subscription forms, social media icons, feedback forms, video presentations and much more.

jQuery Lightbox

Used to add the lightbox effect to images on your WordPress blog 🙂

You can check for more information and samples here.
http://www.pedrolamas.com/projectos/jquery-lightbox-en/

jQuery Lightbox For Native Galleries

Lightbox Gallery,wordpress lightbox plugins
Lightbox Gallery,wordpress lightbox plugins

Makes the native WordPress galleries use a lightbox script called ColorBox to display the fullsize images right there in the page. No modifications required.

Frndzk Photo Lightbox Gallery

Frndzk photo lightbox plugin adds lightbox effect to all photos of every post and pages. it also shows photos in a group of a post like a photo album. it has next and previous to navigate photos. Just install the plugin and see your photos! no setup or configuration needed
demo
http://bitto.us/wp/fpgdemo

most used wordpress functions in theme

In wordpress theming is very important. Developers know the importance of functions.php file. Here we given most used wordpress functions in theme which will be useful for wordpress developer. I always written some very nice code snippets in functions.php file.

most used wordpress functions in theme

I found very useful codes which is very helpful for very wordpress designer and developers.

Here is very useful code snippets.
Enable Hidden Admin Feature displaying ALL Site Settings

// CUSTOM ADMIN MENU LINK FOR ALL SETTINGS
   function all_settings_link() {
    add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
   }
   add_action('admin_menu', 'all_settings_link');

Remove Update Notification for all users except ADMIN User

// REMOVE THE WORDPRESS UPDATE NOTIFICATION FOR ALL USERS EXCEPT SYSADMIN
       global $user_login;
       get_currentuserinfo();
       if (!current_user_can('update_plugins')) { // checks to see if current user can update plugins
        add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
        add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
       }

Include custom post types in the search results.

// MAKE CUSTOM POST TYPES SEARCHABLE
function searchAll( $query ) {
 if ( $query->is_search ) { $query->set( 'post_type', array( 'site','plugin', 'theme','person' )); }
 return $query;
}
add_filter( 'the_search_query', 'searchAll' );

Add your custom post types to your sites main RSS feed by default.

// ADD CUSTOM POST TYPES TO THE DEFAULT RSS FEED
function custom_feed_request( $vars ) {
 if (isset($vars['feed']) && !isset($vars['post_type']))
  $vars['post_type'] = array( 'post', 'site', 'plugin', 'theme', 'person' );
 return $vars;
}
add_filter( 'request', 'custom_feed_request' );

Modify the Login Logo & Image URL Link

add_filter( 'login_headerurl', 'namespace_login_headerurl' );
/**
 * Replaces the login header logo URL
 *
 * @param $url
 */
function namespace_login_headerurl( $url ) {
    $url = home_url( '/' );
    return $url;
}

add_filter( 'login_headertitle', 'namespace_login_headertitle' );
/**
 * Replaces the login header logo title
 *
 * @param $title
 */
function namespace_login_headertitle( $title ) {
    $title = get_bloginfo( 'name' );
    return $title;
}

add_action( 'login_head', 'namespace_login_style' );
/**
 * Replaces the login header logo
 */
function namespace_login_style() {
    echo '<style>.login h1 a { background-image: url( ' . get_template_directory_uri() . '/images/logo.png ) !important; }</style>';
}

Loading jQuery from the Google CDN

// even more smart jquery inclusion :)
add_action( 'init', 'jquery_register' );

// register from google and for footer
function jquery_register() {

if ( !is_admin() ) {

    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' ), false, null, true );
    wp_enqueue_script( 'jquery' );
}
}

Remove the WordPress Version Info for Security

// remove version info from head and feeds
function complete_version_removal() {
    return '';
}
add_filter('the_generator', 'complete_version_removal');

Add Spam & Delete Links to Comments on Front End

// spam & delete links for all versions of wordpress
function delete_comment_link($id) {
    if (current_user_can('edit_post')) {
        echo '| <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&c='.$id.'">del</a> ';
        echo '| <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&dt=spam&c='.$id.'">spam</a>';
    }
}

Remove Default WordPress Meta Boxes

// REMOVE META BOXES FROM DEFAULT POSTS SCREEN
   function remove_default_post_screen_metaboxes() {
 remove_meta_box( 'postcustom','post','normal' ); // Custom Fields Metabox
 remove_meta_box( 'postexcerpt','post','normal' ); // Excerpt Metabox
 remove_meta_box( 'commentstatusdiv','post','normal' ); // Comments Metabox
 remove_meta_box( 'trackbacksdiv','post','normal' ); // Talkback Metabox
 remove_meta_box( 'slugdiv','post','normal' ); // Slug Metabox
 remove_meta_box( 'authordiv','post','normal' ); // Author Metabox
 }
   add_action('admin_menu','remove_default_post_screen_metaboxes');

// REMOVE META BOXES FROM DEFAULT PAGES SCREEN
   function remove_default_page_screen_metaboxes() {
 remove_meta_box( 'postcustom','page','normal' ); // Custom Fields Metabox
 remove_meta_box( 'postexcerpt','page','normal' ); // Excerpt Metabox
 remove_meta_box( 'commentstatusdiv','page','normal' ); // Comments Metabox
 remove_meta_box( 'trackbacksdiv','page','normal' ); // Talkback Metabox
 remove_meta_box( 'slugdiv','page','normal' ); // Slug Metabox
 remove_meta_box( 'authordiv','page','normal' ); // Author Metabox
 }
   add_action('admin_menu','remove_default_page_screen_metaboxes');

Add Custom User Profile Fields

// CUSTOM USER PROFILE FIELDS
   function my_custom_userfields( $contactmethods ) {

    // ADD CONTACT CUSTOM FIELDS
    $contactmethods['contact_phone_office']     = 'Office Phone';
    $contactmethods['contact_phone_mobile']     = 'Mobile Phone';
    $contactmethods['contact_office_fax']       = 'Office Fax';

    // ADD ADDRESS CUSTOM FIELDS
    $contactmethods['address_line_1']       = 'Address Line 1';
    $contactmethods['address_line_2']       = 'Address Line 2 (optional)';
    $contactmethods['address_city']         = 'City';
    $contactmethods['address_state']        = 'State';
    $contactmethods['address_zipcode']      = 'Zipcode';
    return $contactmethods;
   }
   add_filter('user_contactmethods','my_custom_userfields',10,1);

Add an excerpt box for pages

if ( function_exists('add_post_type_support') )
{
    add_action('init', 'add_page_excerpts');
    function add_page_excerpts()
    {
        add_post_type_support( 'page', 'excerpt' );
    }
}

Function to change the length of Exerpt

function new_excerpt_length($length) {
    return 100;
}

add_filter('excerpt_length', 'new_excerpt_length');

Auto Extract the First Image from the Post Content

/ AUTOMATICALLY EXTRACT THE FIRST IMAGE FROM THE POST
function getImage($num) {
    global $more;
    $more = 1;
    $link = get_permalink();
    $content = get_the_content();
    $count = substr_count($content, '<img');
    $start = 0;
    for($i=1;$i<=$count;$i++) {
        $imgBeg = strpos($content, '<img', $start);
        $post = substr($content, $imgBeg);
        $imgEnd = strpos($post, '>');
        $postOutput = substr($post, 0, $imgEnd+1);
        $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
        $image[$i] = $postOutput;
        $start=$imgEnd+1;
    }
    if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; }
    $more = 0;
}

Unregister WP Default Widgets

// unregister all default WP Widgets
function unregister_default_wp_widgets() {
    unregister_widget('WP_Widget_Pages');
    unregister_widget('WP_Widget_Calendar');
    unregister_widget('WP_Widget_Archives');
    unregister_widget('WP_Widget_Links');
    unregister_widget('WP_Widget_Meta');
    unregister_widget('WP_Widget_Search');
    unregister_widget('WP_Widget_Text');
    unregister_widget('WP_Widget_Categories');
    unregister_widget('WP_Widget_Recent_Posts');
    unregister_widget('WP_Widget_Recent_Comments');
    unregister_widget('WP_Widget_RSS');
    unregister_widget('WP_Widget_Tag_Cloud');
}
add_action('widgets_init', 'unregister_default_wp_widgets', 1);

Enable GZIP output compression

if(extension_loaded("zlib") && (ini_get("output_handler") != "ob_gzhandler"))
   add_action('wp', create_function('', '@ob_end_clean();@ini_set("zlib.output_compression", 1);'));

Enable shortcodes in widgets

// shortcode in widgets
if ( !is_admin() ){
    add_filter('widget_text', 'do_shortcode', 11);
}

If you have any interesting code snippets then please suggest me.

most used wordpress functions in theme
most used wordpress functions in theme

checklist for self hosted wordpress sites

When you creating site in wordpress, I created unique checklist for self hosted wordpress sites. checklist for self hosted wordpress sites is very important.

checklist for self hosted wordpress sites

When you creating the website in wordpress that time you need to be very careful and you need think and check about following things. I created the checklist for wordpress sites.

About Theme

Use the Minimum images

checklist for self hosted wordpress sites
checklist for self hosted wordpress sites

You should use the sprite image in wordpress theme. That will reduce the webpage loading time.

Use proper and optimized CSS properties

You should use the proper CSS. Dont repeat CSS code. like float, color, margin.

Test the Theme in IE7, IE8 ,Firefox, Safari and Google Chrome

Your theme need to be cross browser compatible.

Use only External CSS

Dont use the inline CSS in Theme.

Use Jquery

Jquery is very popular and simple and seo friendly for wordpress site.

Use the Sidebars in your theme

In sidebar you mostly put the links and ads. That is very important for SEO.

Put the Tag and category links

You should put the tags and category links in theme.

Make Mobile friendly

You theme should viewable in iPhone, iPad, Blackberry mobile devices.

Check in WordPress site

  • Check Robots.txt file
  • Put Site title
  • Get some good Tagline for the site
  • Create contact us email address
  • Put Share links ie. Twitter, Facebook, MySpace, RSS, LinkedIn etc.
  • Create Author’s profile: Email, Website, AIM, Biographical Info
  • Put the Google Analytics code in your site
  • Do web master varification
  • Use the SEO Meta Tags (Use the SEO Meta Tags plugin)
  • Submit your site to to Yahoo, Google, Bing
  • Use good wordpress plugins
  • Use the Permalinks (date and name. if do not want to show category in url then use ‘No Category Base’ plugin)
  • All Posts and Pages with genuine and useful articles
  • Create nice Categories and their structure (parent-child)
  • Remove broken urls (if urls not provided use ‘javascript:;’ in anchor’s href)
  • Use the Widgets and Menus with their urls
  • Put Akismet API key -For Spam protection.
  • Do setting for Media sizes (thumbnail, medium, large)
  • Uncheck the “Organize my uploads into month- and year-based folders” setting in media setting.
  • Use the SEO ultimate plugin.
  • Dont use the plugin for contact form

Here are some useful links which will be helpful to you

Best WordPress SEO Plugins for Optimize your WordPress Website