Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

Example:

add_action("after_switch_theme", "your_set_tables_function");
share|improve this answer
    
Thanks, that now works flawlessly –  MartinJJ Dec 13 '12 at 23:16

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'); ?> 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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