Run PHP Code in WordPress Posts and Pages


Insert PHP Plugin

Run PHP code inserted into WordPress posts and pages.

The PHP code is between special tags (“[insert_php]” instead of “”).

The PHP code runs as the page is sent to the browser. Output of the PHP code is published directly onto the post or page where the PHP code between the special tags is located.

The code between the tags must be complete in and of itself. References to variables or code blocks outside the area between the tags will fail. See the “more information” URL for an explanation of this.

Using Insert PHP

To use, paste the PHP code into the post or page and then:

Write PHP code between [insert_php] and [/insert_php]

echo "Hello, World!";
echo "You are my friend :)";

Installing Insert PHP

Insert PHP can be installed from the WordPress Dashboard or uploaded to the /plugins directory.

To install from the WordPress Dashboard:

At the “Plugins – Add New” dashboard menu item:

Search for “Insert PHP”

Click the plugin’s “Install Now” link.

To upload to the /plugins directory:

Download Insert PHP from either the plugin page or directly from this link.

Unzip the downloaded file.

Upload the unzipped “insert-php” directory to the WordPress /plugins directory.

When Installed or Uploaded:

After Insert PHP has been installed via the dashboard or uploaded into the /plugins directory, activate the plugin.


Bypass FTP in wordpress


Write below lines at the end of  your wp-config.php
define( 'FS_METHOD', 'direct' );
define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );

Add Custom Shortcode in any Post Type


If you need to add custom shortcode in your site then this article is useful to you.

Add below Function in your theme’s function.php.

function get_value($atts) {
$output = $arr[$atts['key']];
return $output;

add_shortcode('variable', 'get_value');


[variable key="IMAGE_PATH"]

add above line in worpress editor(in your post).

Also refer this link for more detail.

Permalink Editor


This plugin adds two areas of functionality: Global page, category or tag permalink structures and individual custom permalinks.

Options are added to the Permalinks Settings page allowing you to specify the structure for pages, categories, tags and authors.

By default – if custom permalinks are enabled – pages are accessible in the format /page/ or /parent/page/.

You can modify this format in many different ways, for example:

  • Add an extension: /%pagename%.html
  • Add a parent directory name: /content/%pagename%/
  • Prefix the page name: /page-%pagename%/
  • Or using a combination of the above.

This same format applies for categories, tags and authors, however the structure tokens differ:

  • Categories: %category% (E.g. /category/%category%.html)
  • Tags: %post_tag% (E.g. /tag/%post_tag%.html)
  • Authors: %author% (E.g. /author/%author%.html)

Each permalink base can be edited directly via these settings, for example using /people/%author%.html as the Author permalink structure will replace /author/ with /people/.

If no prefix is found, permalinks will be prepended with a default (category, tag or author) – with the exception of pages.

Note: Ensure you have included the correct structure tag somewhere in the url.

Additionally, an option is added to the edit screen allow you to specify the permalink for an individual post or page.


  1. Unzip inside the /wp-content/plugins/directory for your site (or install via the built-in WordPress plugin installer)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  3. Use %category% as a permalink tag in the Settings -> Permalinks admin options page when defining a custom permalink structure


After Fresh Installation of Linux


Basic Linux commands which will be required after new installation


Login as root


sudo su


Install MySQL 5


apt-get install mysql-server mysql-client


Installing Apache2


apt-get install apache2


Installing PHP5


apt-get install php5 libapache2-mod-php5


and then, restart apache — /etc/init.d/apache2 restart


Getting MySQL Support In PHP5


To get MySQL support in PHP, we can install the php5-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this: 

apt-cache search php5 

Pick the ones you need and install them like this: 

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl 

Now restart Apache2: 

/etc/init.d/apache2 restart


Install phpMyAdmin

sudo apt-get install -y mysql-server


phpMyAdmin is a web interface through which you can manage your MySQL databases. It’s a good idea to install it:

apt-get install phpmyadmin


Change required to browse phpmyadmin


  1. Open /etc/apache2/apache2.conf
  2. Add following line at last: Include /etc/phpmyadmin/apache.conf


Run Below Command, if you are getting apache could not reliably determine domain name error while restarting apache service


sudo sh -c ‘echo “ServerName localhost” >> /etc/apache2/conf.d/name’ && sudo service apache2 restart



Install SVN:


sudo apt-get install subversion libapache2-svn


1) Create SVN Repos

=> sudo svnadmin create /var/lib/svn/repo_name


2) Give permissions to created repos

=> sudo chown -R www-data:www-data /var/lib/svn/repo_name


3) Checkout from svn repos into your /var/www/

=> svn co


4) Create new SVN user

=> sudo htpasswd -m /etc/apache2/dav_svn.passwd user_name


Enable mod_rewrite


a2enmod rewrite


phpmyadmin without password


Open etc/phpmyadmin/

// $cfg[‘Servers’][$i][‘AllowNoPassword’] = TRUE;

uncomment above line, it should read as follows

$cfg[‘Servers’][$i][‘AllowNoPassword’] = TRUE;


Anybody interested in sublime text editor

add-apt-repository ppa:webupd8team/sublime-text-2

apt-get update

apt-get install sublime-text


If CURL is not working try following

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl


sudo /etc/init.d/apache2 restart


To Display Errors 

Open php.ini file – sudo gedit /etc/php5/apache2/php.ini

search for – display_errors

uncomment – Default Value: On

search for – error_reporting

uncomment – Default Value: E_ALL & ~E_NOTICE


Access WWW directory

cd /

cd var


Change owner to your user for complete access

chown -R <your_user_name>:<your_group_name> <path_to_directory>

<your_user_name> would be generally ‘administrator’



Other SVN Commands

Update SVN files

svn up


Commit files to SVN repository

svn ci -m “your comment for this commit” <files>

Add new files to SVN

svn add <file_name or dir_name>


Delete SVN file

svn delete <file_name or dir_name>


Yii framework Live svn checkout URL

svn checkout yii



Enable .HTACCESS on localhost

1) To make .htaccess files work as expected, you need to edit this file:



2) Look for a section that looks like this:

<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all

# Uncomment this directive is you want to see apache2’s

# default start page (in /apache2-default) when you go to /

#RedirectMatch ^/$ /apache2-default/



3) You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it’s okay to allow .htaccess files to over-ride previous directives. You must restart Apache after the change

sudo /etc/init.d/apache2 restart


PHP.INI settings to be done

1) Open file :- /etc/php5/apache2/php.ini

2) Change below values as per requirement


upload_max_filesize = 128M

max_execution_time = 30 ; Maximum execution time of each script, in seconds

max_input_time = 60 ; Maximum amount of time each script may spend parsing request data

memory_limit = 4M ; Maximum amount of memory a script may consume (16MB)

3) Restart Apache



Enable Remote Access in mysql / Binding Database


To install safari and other window software in Ubuntu


To install opera in Ubuntu


How to create Virtual Host into Ubuntu:


How to convert / cut videos:


avconv -ss <start-time> -t <duration> -i long-video.mp4 -codec copy funny-clip.mp4


MySQL backup and restore databases



mysqldump -u root -ptmppassword –all-databases > /tmp/all-database.sql


To restore the sugarcrm database, execute mysql with < as shown below. When you are restoring the dumpfilename.sql on a remote database, make sure to create the sugarcrm database before you can perform the restore.

# mysql -u root -ptmppassword

mysql> create database sugarcrm;

Query OK, 1 row affected (0.02 sec)

# mysql -u root -ptmppassword sugarcrm < /tmp/sugarcrm.sql

# mysql -u root -p[root_password] [database_name] < dumpfilename.sql


Mail Service:


Ubuntu 12.04 LTS LAMP Server Setup


Netbeans Installation:




Remove all SVN folder from Directory 

Try this:

find . -name .svn -exec rm -rf {} \;

Before running a command like that, I often like to run this first:

find . -name .svn -exec ls {} \;

Multiple Image Preview using jQuery


=>put div in your view file:-

<input type=”file” name=”uploadedImages” id=”uploadedImages” ‘onchange’ = ‘readURL(this);’>

<div  id =”up_images”>

=> your jQuery:

function readURL(input) {


   var number = 0;

   $.each(input.files, function(value) {

       var reader = new FileReader();

       reader.onload = function (e) {

           var id = (new Date).getTime();


           $(‘#up_images’).prepend(‘<img id=’+id+’ src=’’ width=”100px” height=”100px” data-index=’+number+’ onclick=”removePreviewImage(‘+id+’)”/>’)