How to move an array Element to any other index?

<?php $array = array(‘a’, ‘b’, ‘c’, ‘d’); function move_array_element(&$array, $element_index, $required_index) { $out = array_splice($array, $element_index, 1); array_splice($array, $required_index, 0, $out); } // Let’s say I want to move Element “d” to index 2 // So first I’ll find it’s index dynamically $element_index =array_search(“d”, $array); $required_index = 1; move_array_element($array, $element_index, $required_index); print_r($array); /* Result: Array […]

how to create custom admin page?

In this article I’ll show how to create custom page for admin panel. <?php // Following code is just example to show how this works. So obviously you can alter this or write your own code for UI // function that will prpeare User Interface for our New Admin Page function az_admin_custom_page() // You can […]

How to setup Google reCaptcha Version 2.0?

To setup Google reCaptcha oepn url and fill form as shown in the screenshot below: After registration open newly created reCaptcha site and read the guide provided by google as shown below: Now paste <script src=’’></script>  in <head> or anywhere before use of captcha. And then paste <div class=”g-recaptcha” data-sitekey=”6LcPQggTAAAAAAw-SQm8KTEW-N1CBuzBz_gW71UT”></div> to the place where you want to show captcha […]

WordPress: How to submit custom form data using Ajax?

In wordpress we send data using same ajax method as we do in regular non-wordpress website.  The difference is few additional data variables and filter on serverside. To Implement this I created a template page named “Request a Quote” in request-a-quote.php, created new wordpress and assigned that template to this page.

PHP: How to search and replace string from complete database using PHP

If you want to search and replace string from entire database (from all tables of any database) using php then use following code. <?php // Find and replace facility for complete MySQL database // // Written by Mark Jackson @ MJDIGITAL // Can be used by anyone – but give me a nod if you […]

MySQL: How to duplicate a row using SQL ?

Use following SQL query to duplicate any single row. Use your own field names to make this working in your case. insert into packages (`field_1`, `field_2`, `field_3`, `field_4`) select `field_1`, `field_2`, `field_3`, `field_4` from packages where id=1  

How to create Custom 5 Stars Rating System in WordPress?

In this article I’ll show that how to create custom 5 stars Rating system in wordpress. I’ll create WordPress Short Code to place rating anywhere in any post. Steps: 1- Create Directory “az_rating” in the root folder of your active theme. 2- Create rating.php in az_rating/ folder. In this file we will write all code for […]

How to create custom widget Area in the admin Widgets page?

To create custom widget area we will need functions.php file (should be in the root directory of the theme) to add some custom code. We use wordpress filter “widgets_init”. <?php function register_my_sidebar() { $args = array( ‘name’ => __( ‘Footer 1’, ‘theme_text_domain’ ), ‘id’ => ‘footer-widget-1’, ‘description’ => ”, ‘class’ => ”, ‘before_widget’ => ‘<li […]

Wordpess: How to display the WCK Plugin’s Custom fields in the page or post?

$meta = get_post_meta(get_the_ID(), ‘name_of_meta’, true); // name_of_meta is the name of meta box linked the the current post ID. $meta = $meta[0]; // Now in $meta variable we have all fields available in this meta box which we added in the WCK custom fields section. // We can access fields as shown below: echo $meta[‘field1’]; […]

WordPress: How to display navigation menu in your custom theme?

<?php $defaults = array( ‘theme_location’ => ‘primary’, ‘menu’ => ”, // name of the menu you created in the menus ‘container’ => ”, ‘container_class’ => ”, ‘container_id’ => ”, ‘menu_class’ => ”, ‘menu_id’ => ”, ‘echo’ => true, ‘fallback_cb’ => ‘wp_page_menu’, ‘before’ => ”, ‘after’ => ”, ‘link_before’ => ”, ‘link_after’ => ”, ‘items_wrap’ => […]