WordPress disable parent menu using jquery

<script language=javascript>
  jQuery("#menu-firstmenu li:has(ul.sub-menu)").hover(function () {
     jQuery(this).children("a").click(function () {
        return false;

Posted in jquery, WordPress | Tagged , , | 7 Comments

WordPress Posts Counter Widget

I have created a small widget to show total no of posts on your blog.You just need to copy this code and save the file in plugins folder and activate plugin.

After that you can drag and drop widget in your theme.

Plugin Name: Posts Counter
Description: A plugin which allows you to show total number of Posts on your blog.
Author: Kapil Chugh
Author URI: https://kapilchugh.wordpress.com/
Plugin URI: http://mediologysoftware.com/
Version: 0.1
add_action( 'widgets_init', 'add_posts_counter' );
function add_posts_counter() {
register_widget( 'WP_Widget_Posts_Counter' );
class WP_Widget_Posts_Counter extends WP_Widget {
function WP_Widget_Posts_Counter() {
$widget_ops = array('classname' => 'widget_featured_entries', 'description' => __( "This widget will show total no of posts on your site") );
$this->WP_Widget('posts_counter', __('Posts Counter'), $widget_ops);
$this->alt_option_name = 'posts_counter_widget';
function widget($args, $instance) {
$title = apply_filters('widget_title', empty($instance['title']) ? __('Posts Counter') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ( $title ) echo $before_title . $title . $after_title;
$num_posts = wp_count_posts( 'post' );
echo 'Total Posts ' . $num_posts->publish;
echo $after_widget;
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
function form( $instance ) {
$title = isset($instance['title']) ? esc_attr($instance['title']) : ''; ?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
Posted in WordPress | Tagged , | 13 Comments

Add read more link in excerpt

By default wordpress adds [..] after every excerpt.I have created a function to remove this sign add your own text.

You just need to add this in your functions.php file

add_filter(‘wp_trim_excerpt’, custom_excerpt);
function custom_excerpt($text) {
$text = str_replace(‘[…]’, ‘<a href=”‘ . get_permalink() .'”>..Read More</a>’, $text);
return $text;

Posted in WordPress | Tagged , | 1 Comment

Ubuntu upgrade from 8 to 10

Press Alt-F2 and type update-manager --devel-release

Complete Description can be found at this link


Posted in Ubuntu | Tagged | Leave a comment

Move ubuntu panel bar

(1)Right Click on panel

(2) Click Properties

(3) Uncheck Expand

(4) Change Orientation or drag and drop.

(5) Again check Expand

Posted in Ubuntu | Tagged , | Leave a comment

Most important vim editor commands in ubuntu

There are two modes in Vim Editor Command mode and Insert mode.By default when we open a new file we are in command mode.

So to go from command mode to insert mode we enter i

and to go insert  mode to command mode we use ESC

for eg.

Open a new file

(1) type vim test (creates a file named test)

(2) type i ( switch to insert mode)

(3) enter text (any text)

(4) hit Esc key (switch back to command mode)

(5) type :wq (write file and exit vim)

Now these are the basic commands to work in vim.There are some other commands also.So first we need to enter into command mode that we can do by hitting ESC key and then.

To Save text                                :w

Quit                                              :q

Quit  without saving                  :q!

Search                                        :/SEARCH_TEXT

Continue  Search                      :n

Line number                             :set nu

Copy                                         :5yy(it will copy  5 lines starting from cursor)

Paste                                         :p(will paste 5 lines that  we copied earliar)

Delete                                       :dd (will delete current line)

Posted in Ubuntu | Tagged , | Leave a comment

WordPress 3.0 features.

(1) Merging of wordpress and wordpress mu.

(2)Custom Post and Custom Taxonomies.

(3) Featured image on Posts page.

(4) Custom menu management feature.
(5) Custom header and background APIs.
(6) Custom Username and password.
(7) Shortlinks.

(8) New login form with wp_login_form();

(9) Custom author page.

(10) Introduce child theme concept.

(11)Post editor style using add_editor_style()

Posted in WordPress | Tagged | Leave a comment