All Stories

How to get top parent page ID in wordpress

The solution to get the top parent page id is here, it is quite easy without using any recursion function. function get_top_parent_page_id() { global $post; // Check if page is a child ...

How to validate email id in javascript

Find the below code by which you can validate the email field using java-script on client side, var reg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/; if(!reg.test(document.getElementById(“email”).value)){ alert(“Please ...

How to export Email List from cpanel using javascript and firebug

To export the email address with the help of java-script: Login your cpanel and select the Email Accounts under the Mail section and change the result per page to show all the emails. Now ...

Mysql if condition in update query

We can use the IF CONDITION in update query, given blow example will show how we can use the IF Condition in update query. Suppose we have a table that has 2 column first is Name and ...

Add/Remove unwanted links from wordpress admin bar

Remove links from wordpress admin bar: Given below code remove the wordpress logo and other links from the admin bar. function annointed_admin_bar_remove() { global $wp_admin_bar; /* ...

Remove unwanted menu/submenu links from wordpress dashboard

Remove menu page links: function remove_menus() { global $submenu; remove_menu_page( ‘link-manager.php’ ); // Links remove_menu_page( ‘edit-comments.php’ ); ...

Get customize categories in wordpress

The following example will show the categories with checkbox <?php $args=array( ‘child_of’ => ‘1’, ‘hide_empty’ => ‘0’ ); $categories ...

Add Custom Post Type Counts to the Dashboard

we have several ways to add custom post type counts to the dashboard including right_now_content_table_end. For Example: function add_area_counts() { if (!post_type_exists(‘escorts’)) ...

PHP5 Static Keywords

PHP5 offers a static methods and static member variables.A special kind of method that can be called without instantiating a class.Static methods don’t depend on the properties of ...

PHP5 Interfaces

An interface simply lists (function prototype) the methods a class must implement. However, in PHP a class can implement multiple interfaces and these interfaces can also be used in ...

PHP5 Abstracts

Abstract classes and methods are introduced in PHP 5. The concept behind the abstract class is that we need to extend this class by its descendant class(es). If a class contains abstract ...

PHP Final Keywords

Final Keywords prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended. Final keyword ...

Calculate average and sum from Mysql query

The AVG function return the average value of the specified column. For example I have a table of product list and now I want the total of price and average price of all the products. id name price 43245 Jeans 19.99 43246 Top 3.99 43247 Playstation 89.95 43248 Men’s ...

Add Custom Link to WordPress Admin Bar

With the use of this plugin you can add custom link in your wordpress admin bar. You can also add child link of the parent link. Installation: Download the plugin and unzip it. Put ...

Change wordpress excerpt length

Copy and paste the given blow code in your theme functions.php file which will change the length of the wordpress excerpt function. function ratanjyot_solutions_excerpt_length($length) ...

Customize wordpress excerpt ellipsis with post permalink

Copy and Pase the given blow code in your functions.php file. This code will replace the ellipsis with post permalink. function new_excerpt_more($content) { return ‘<div><a ...

How to Replace Newline with Space Using PHP

Sometimes you need to replace newline to space or any other format (i.e:- \r\n). This is done by copying and pasting the content. To resolve this problem I use the given blow code. $remove_character ...

What is the difference between MyISAM and InnoDB?

The main difference between mysql table type MyISAM and InnoDB is that InnoDB supports transaction by MyISAM does not. MyISAM support full text search but InnoDB does not. InnoDB supports ...

Show wordpress search result in Ascending order

WordPress shows search result always in descending order to change it into Ascending order follow the given blow instruction. Change this line <?php if(have_post()): ?> to <?php ...

How to get number of days between two dates in PHP

By the given blow script we can find the number of days between two dates <?php $first_date = strtotime("2010-08-01"); // or current date as well $second_date = strtotime("1988-08-01"); ...
hide-update-reminder-message1

Hide Update Reminder Message

With the use of this plugin you can hides update reminder message from the WordPress Admin for all non admin users and for Admin also. You can change the setting from the WordPress ...

Show Top Comments or Commentators In WordPress Without A Plugin

Here is a simple code snippet to show the top commentators or comments in the wordpres without any plugin. The code are given blow. function top_comment_authors($amount = 5){ global ...

Get current URL in PHP

Sometime, you need to get a current page URL that is shown in the browser address bar. Here is a small code to get the current url. $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'] .$_SERVER['REQUEST_URI'] ...

Change iframe url using javascript

If you want to change the iframe url from the iframe window, you can use this small function to change the url of the iframe. <script type=”text/javascript”> $(document).ready(function() ...
iframe

Open link in parent from child window or iframe using javascript

If you want to control parent window’s URL from the child frame or child window you can use “window.parent” to control the parent window. The complete solution is: <script ...

Find latitude and longitude using google map API

Find coordinates by moving around the map 1. Drag and drop the map to broad location. 2. Zoom in for greater accuracy. 3. Drag and drop the marker to pinpoint the place. The coordinates ...

Add custom or extra fields on registration page in wordpress

Open your theme’s function.php file and drag this PHP code in. <?php // This function shows the form fiend on registration page add_action(‘register_form’,’show_first_name_field’);   // ...

Adding custom user profile fields in wordpress

Open your theme’s “functions.php” file and this PHP code in your file. <?php add_action( ‘show_user_profile’, ‘show_extra_profile_fields’, ...

Calculate week in PHP

Use this script to calculate a week in PHP <?php $date = mktime(0, 0, 0, 01,27, 2011); $week = (int)date(‘W’, $date); ?>

Remove admin color scheme picker from profile

Add this script to the functions.php of your wordpress theme will remove the admin color scheme picker from the profile page. if(is_admin()){ remove_action(“admin_color_scheme_picker”, ...

How to check date if date is between two date

This function the return the true and false if date is exist or not exist. function dateWithin(StartDate,EndDate,CheckDate) { var b,e,c; s = Date.parse(StartDate); e = Date.parse(EndDate); c ...

Fix wordpress plugin profile pic error

The error of the profile pic has been fix. The error was in the new version of wordpress is not upload the profile picture. Solution to resolve this problem Open the profile pic plugin ...

Add a trailing slash to requested urls

Without trailing slash URL shows URL count as a page and with trailing slash it’s count as directory. Search engine gives the high priority to directory in comparision of page. The ...

Error reporting and debugging in codeigniter

To Turn off Debugging Set the db_debug value(in the application/config/database.php config file) to false To Turn off Error reporting Set the Envirement value(in the top of the main ...

How to redirect my website to be opened through HTTPS?

In order to redirect your website to be opened through HTTPS, you should add the following rewrite rule in your .htaccess file:  RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ...

How to make a dynamic tree structure menu

To make dynamic tree structure menu, We have to make to functions one is for “Parent Menu” and second for “Child Menu or Sub Child Menu”. $query = “select ...

How to disable auto save, post revision and reduce the database size in wordpress

The auto save option in wordpress is a best feature but not for every. For those who have limited web space, limited database size and they not want to auto save or post revision option ...

Get image URL from post in wordpress

To get the image URL of post thumbnail in wordpress is little difficult because the wordpress doesn’t provide any function to get the image URL. It only returns the full HTML ...

How to fetch current date and time using Javascript

JavaScript Current Time Clock With the newly created Date Object we can show the current date and time, now only a variable which store the current date and time. We have to only print ...

Force download using PHP

A force-download script can give you more control over a file download than you would have providing a direct link. Using a force-download script, you can: Download image file Download ...

W3C Validation: IFrame Error with XHTML 1.0 Strict Doctype

When you use iframe with XHTML strict Doctype 1.0 then, you can not pass the w3c validation check. You always get an error because iframe is not supported XHTML 1.0 strict Doctype. Errors ...

How to use ASCII value with PHP

Character encoding is useful in web development for generating character strings from random numbers (CAPTCHA images for instance), displaying non-standard characters and many other ...

How to show the jquery Progress bar

The progress bar is used to show the current overall percentage of the process . To show the progress we will use jquery. Code to show progress bar: <!DOCTYPE html> <html> <head> ...

How to show the size of folder using PHP with progressbar

To show the details of folder, first of all we check that, it is folder of file. If it is a folder then we count the number of files present in that folder and add the size of these ...

Rewrite dynamic URL to static URL in PHP using .htaccess

When search engine visits the dynamic url site i.e http://sumitbansal.com/category.php?p=10, so it does not gives the more importance to this page because it keeps on chainging. So ...

How to use meta tag and description dynamically for wordpress

To use meta tag and description in wordpress dynamically, we use the wordpress tags as a meta tags and excert content use as a meta description. As per the requirement description should ...

How to use featured image in wordpress

To use featured image in wordpress, You must add this line in your functions.php file if ( function_exists( ‘add_theme_support’ ) ) { add_theme_support( ‘post-thumbnails’ ...

How to upload multiple files at a time

To upload a file first of all you have to set the form  “enctype” Like the given blow example. <form id=”form1″ name=”form1″ method=”post” ...

Find a content with post id in wordpress

The following example will show the content of post id 30 <?php $postid = 63;//This is page id or post id $post = get_post($postid); $title = $post->post_title; $content = $post->post_content; $content ...

Adding And Subtracting Dates in PHP

Here are some examples by which you can add or subtract date. e.g these simple codes can find the 2 week before or after date. Subtracting Years from a date $date = “1988-08-01”; $newdate ...

Get country from ip-address

Get country name from ip-address <?php function countryCityFromIP($ipAddr) { //function to find country and city from IP address //verify the IP address for the ip2long($ipAddr)== ...

How to check login status in wordpress

Using “is_user_logged_in” function You can check user login or not. e.g <?php if(is_user_logged_in()): ?> echo “Insert your HTML or PHP code here”; <?php ...

How to check file is exist or not using php

We can check the file is exist or not in the folder using  file_exists function Here is a simple code to check the presence of the file $add="images/119.jpg"; if(file_exists($add)) { echo ...

how to fetch all files from folder using php

PHP directory listing Some times we have to display the list of all files in a directory.We can do this with the help of php function readdir(). The code to display all the files is ...

Protect your folder or folder lock without any Software

We can protect or lock any folder without any software with few steps Open notepad and copy the below code and save as lock.bat.You can save also any other default name. At first time ...

How to create hindi texbox

We can create a hindi textbox & textarea with the help of JavaScript in which we can write in hindi and english both. You can download this pack by clicking here

How to delete the file using php

We can delete the file using php with the help of unlink function. Define this function like this: unlink ( string $filename [, resource $context ] ) Parameter: File name: Path ...

How to Create a Folder/Directory using php

We can create a folder with the help of mkdir already defined function We can use tis function like this Description: bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive ...

use rich text editor(RTE) with html, php and .net code

The rich text format (RTF) contain the html code by this we can easily store the format of text in the database and also we can show this format directly on the website page. When we ...

How to Create a auto scheduling task Using PHP (Cron Job or Scheduled Task)

Basically, we will start by creating a schedule. Then, we will feed this schedule to a program called crontab. Crontab will take the schedule and install it into an internal set of ...

Making a PayPal Form to accept a payment on our site

PayPal makes doing this very easy by providing those “Buy-It-Now” buttons you’ve probably seen around the place. Basically when you see one of those buttons, it is really the ...

How to calculate difference in days between two dates in MySQL

Let’s say we have a MySQL table where one column (date or datetime type) is named creation-date and contains dates in one of the YYYY-MM-DD or YYYY-MM-DD HH:MM:SS formats from ...

PHP mailer with attachment with out storing file at your server

Code for sending Email with out storing it at your server, can handle any size and type of file. Most useful when working with files which can contain virus in comments, resumes or ...

A PHP Trick to Override the php.ini Configuration

I’m glad that my hosting provider lets me edit the php.ini configuration file directly inside of the Control Panel. But many hosting providers don’t let their users to edit the ...

Turn off all errors using PHP

If you want to turn off all the warning or errors which shows on the dynamic pages, so you can do it with the help of PHP Function. The Function is: error_reporting(0); You can use ...

Refresh your parent Window after closing pop up window

You could refresh your parent window after closing the pop up window from many methods. From those method some is given blow. 1. Firstly You can make function and call this function ...

Run the .php extension(or .shtml, or .asp, etc), code in .html file

Google strictly follow the .html or .htm extension when it indexed your website if it find the .php extension(or .shtml, or .asp, etc), it execute your web page before indexed by this ...

How to resize a image using PHP

You can re-size any image with the help of PHP, By this script the image will be re-size in the ratio, it means the quality of the image will be same. Image resizing code $tsrc1 = "path ...

How to Create a Favicon for Your Website

You can create Favicon for your website with the help of Favicon Creator. It’s work on your computer not online The example of favicon is shown in the images with the rounded ...

Using String Position and Substring to Extract a Portion of a String using PHP

We’re going to use several string functions together. Let’s take the string testing testing Username:Michele Davis and retrieve only the name. Using several functions together ...

Checking for a String using PHP

To detect whether a string is part of another string, use strstr. This function takes two parameters: the string to search through and the string to search for. It is not case sensitive; ...

Changing Case (Uppercase to lowercase or inverse) using php

PHP provides functionality for changing the case of a string to all uppercase, all lowercase, or the first letter of a word to uppercase. The commands are strtoupper, strtolower, and ...

Calculating the length of a string using PHP

The PHP function strlen can be used to find out how many characters are in a string. This is very useful for validating that there’s data in a string, and that a string isn’t ...

Cutting up strings or Extract a portion of a string using PHP

The substring functions provide a way to extract a portion of a string. All that’s needed is the string to work with, the position to start from, and how many characters to extract. ...

Auto update your twitter account when you update your wordpress blog

You can update your twitter account update automatically when you update your wordpress blog. It is possible with the help of Tweet-this Plugin. This plugin can also tweet new blog ...

How to Update your WordPress Blog

Update your wordpress old version into current new version following steps to update your Blog Check Requirements Take a Backup of Your Database Disable Plugins Ready to Update Now ...

How to Customize Permalink to make search engine friendly?

Search engines always give importance to URLs, post titles, post introduction area (first Para). So you should customize your URL With post name. To do that, select ‘Custom structure’ ...

How to Change Permalinks?

1. Login to your wordpress dashboard. 2. Go to ‘Permalinks’ settings option under ‘Settings’ in left navigation. 3. You can see some common settings there. They are 1. ...

Paging in PHP (Splitting records into pages)

Paging means showing your query result in multiple pages instead of just put them all in one long page. Imagine waiting for five minutes just to load a search page that shows 1000 result. ...

How to Use Rupee Symbol in MS Word? How to type Rupee symbol in my computer?

The Indian Rupee Symbol was supposed to be chosen from one of the 5 shortlisted candidates. However, according to reports from Indian Express IIT Post Graduate student D Udaya Kumar’s ...

Upload a file via FTP using PHP

You can upload a file via FTP using PHP with the help of “ftp_put()” function. upload.php file

Redirect Your webpage with PHP

You can redirect your web-page with the help PHP code

Redirect Your webpage with JavaScript

If you want to redirect your web-page to another location with the help of JavaScript. so you can redirect it with JavaScript function setTimeout("url".time); complete code is <script ...

Show the current value of Dollar in Rupees

This Script Show the current value of rupees in dollar.It is work on google API, the url of the google API calculater is http://www.google.com/ig/calculator?hl=en&q=1USD=?INR Via ...

Install a window via a Pendrive

If you want to install a window via a pendrive or USB Pen you have to download a Software i.e. WinSetupFromUSB-0.1.1. after that u install this softare in your computer and insert your ...
© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie