Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By colingreig

Thread: How to set a custom form for ALL your categories

  1. #1
    Thread Starter
    Amateur colingreig's Avatar
    Join Date
    Jun 2012
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.
    samcy likes this.

  2. #2
    Member echo08's Avatar
    Join Date
    Nov 2011
    Location
    Philippines
    Posts
    68
    Thanks
    25
    Thanked 1 Time in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!
    Please have a time to look @ my website. and leave a comment on how to make it better thanks
    My Website

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. multiple drop-down search form using custom fields and custom taxonomies [part 2]
    By davidhaz in forum ClassiPress General Discussion
    Replies: 12
    Last Post: November 4th, 2014, 07:40 AM
  2. Adding custom form to all categories
    By kehari in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: April 18th, 2013, 09:57 PM
  3. [SOLVED] Listing categories missing in custom form in Chrome
    By shunarjuna in forum Report Vantage Bugs (Legacy)
    Replies: 17
    Last Post: November 21st, 2012, 05:53 PM
  4. [TUTORIAL] multiple drop-down search form using custom fields and custom taxonomies [part 1]
    By davidhaz in forum ClassiPress General Discussion
    Replies: 6
    Last Post: June 6th, 2011, 06:40 AM