How to set a custom form for ALL your categories
I imported ~800 categories and I wasn't looking forward to checking off 800 tiny checkboxes. Looked for a solution here but only found dead end threads with others asking the same thing.
Decided to give it a shot.
I can see in the table "wp_cp_ad_forms" that the field "form_cats" contains the list of applicable categories for that form. The data is serialized so you can't just type dump in a list of category ID's you have to play with it first.
Step 1:
Grab the following php code, save it to a file (test.php) and load it on your server so you can run it.
HTML Code:
<?php
// Author: www.colingreig.com
if(isset($_POST['q'])) {
$q = $_POST['q'];
// split lines by line break (\n)
$data_array = split("\n", $q);
// remove trailing spaces
$data_array = array_filter(array_map('trim', $data_array));
// serialize for mysql
$serialized = serialize($data_array);
echo "<textarea>".$serialized."</textarea>";
}
?>
<h2>Enter categories, one per line</h2>
<form method="post" action="test.php">
<textarea name="q" col=10 rows=10><?php if(isset($_POST['q'])) echo $_POST['q']; ?></textarea>
<input type="submit" />
</form>
Step 2:
Head to wp_term_taxonomy, export the data as CSV, bring it into excel and sort it by column "taxonomy" to get a list of "ad_cat" entries. Grab all the "term_id" that have a taxonomy of "ad_cat" and then copy them into the script. Press
Step 3:
Press submit, you should now have a new textarea box with your serialized list of cat_id's ready to put into the "wp_cp_ad_forms" table, in the field "form_cats"
It's not pretty but it works.