I have been tasked with creating a theme that will be a base to list the site owners ebay store products.

I have fleshed most of the project out in plain old php to get everything working as regards to adding the listings via the ebay api, right now im integrating the code into functions.php of the custom theme.

What i need to do is create database tables in WP to hold the ebay xml file values from various xml files, following the codex i can see how it is done via plugin activation, My question is how can i do it directly via the themes functions.php on theme activation following the codex it does not work which im guessing is down to require_once ABSPATH


In functions.php you can create "your_set_tables_function()" and then hook it in the "after_switch_theme" hook.


add_action("after_switch_theme", "your_set_tables_function");

Create a function called theme_activation_function and execute the code that creates your table inside it.

By adding the after_switch_theme action, when YOUR theme is enabling the function runs! :)

<?php add_action('after_switch_theme', 'theme_activation_function'); ?> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.