Converting multiple XML files to single JSON by PHP


Hits: 5

ACF, Filter and Hooks, Programming, WordPress

Saving the CF7 submission in the Dashboard using ACF

1. First, create an acf options page. I am creating Cf7 Submissions as my option page where I will list all my form submissions values

2. Create a form using CF7. I am using the default form cf7 provides

3. Create a repeater field in acf to save the form submitted values in the database and assign it to Cf7 Submissions options page

4. CF7 provides hook wpcf7_before_send_mail which enable us to process the  submiited data the way we like before submitting the form. I am using this hook to save the form submission in the dashboard

5. update_field updates the values in the database
We are capturing the previously submitted data, so that we could merge it with the new submitted form values .

Note : The previously saved data’s in the repeater fields are lost if we don’t merge and update it with the new data’s submitted by the form

6.  Check the cf7 submission options page to see the lists of saved submitted form fields in the dashboard


Hits: 8

Programming, WordPress

PHP code to Import the taxonomy terms from one website to another

1. Create a folder in the root directory of the site i.e PARENT_SITE from where we want to export the Taxonomy Terms. I have created services folder in the root directory and created the php file named books-category.php

2. Include wp-load.php the files so that we could use all the WordPress available functions

3. Write a code that echo’ s JSON representation of a terms related to book taxonomy . We can replace the taxonomy name by any other taxonomy we want to import


We can check the encoded taxonomy terms in the Url : http://PARENT_SITE/services/books-category.php

4. Create a folder in the root directory of the site I call it as CHILD_SITE where we want to import the Taxonomy Terms.

I have created app folder in the root directory of CHILD_SITE and created the php file named import-books-taxonomy.php :

5. Create a two meta field to store the parent id and the id of taxonomy terms OF the PARENT_SITE in the same taxonomy of CHILD_SITE .

We can use acf to create the meta/custom field in the taxonomy :

6. We can Use Guzzle to parse the json response from the MAIN_SITE :

7. Write a code to read the JSON formated terms and insert terms in database

8. When imported, term is inserted in the database of the CHILD_SITE, the id of the inserted term is different than the PARENT_SITE term id . Therefore, PARENT_SITE term_id and parent_id of terms are saved in the CHILD_SITE of related taxonomy terms, so that it could be usedful in the future.

9. Run File to import the taxonomy terms, http://CHILD_SITE/app/books-category.php

Hits: 6

Programming, WordPress

Fix Fatal error: Maximum execution time of 30 seconds exceeded

In WordPress, maximum execution time fatal error is seen when trying to update theme or plugins. Usually the problem occurs when a code takes a long time to run and reaches the maximum time limit set in the hosting server.

To fix the error,

1. Find your .htaccess file in the root directory, add the below line of code at the bottom of your .htaccess file and save it. The code sets the maximum execution time to 300 secs .

After saving the .htaccess file, check if the error still exists. If this doesn’t fix the issue, check the issue by increasing the maximum execution time to 600 secs

2. Create a php.ini file inside your WordPress root folder , add the following line in the php.ini file and save it.

Check your website to see if the error has gone.

3. If both of the aforementioned methods don’t fix the issue, contact your hoster for assistance.

Hits: 14

Filter and Hooks, Programming, WordPress

Get Menu Items Based on Custom Menu

1. Register your custom navigation menu.
We have readily available funtion to register our custom menu, therefore we do not need to call add_theme_support( ‘menus’ ) :


Here, $locations is an associative array of menu location slugs (key) and descriptions (according value). I have registered custom menu ‘primary_menu’ as a key  and ‘Main menu’ is the description for the registered ‘primary_menu’


2. Create and add Menu items the dashboard


3. Get the array of Menu items

Use the custom menu key ‘primary_menu’ in my case to get the  all the menu items associated with it.


4. Function to the get the array of menu items

You can create your own function to get the menu items and its sub-items in an array


Hits: 13