WordPress: Creating a search form for custom post types

What should I look into if I want to build a form that searches through custom post types, i.e. a completely rebuilt form? Creating the actual form and it’s elements is no problem but the next steps brings up a lot of tricky questions such as,

  1. How can I pass $_GET data to another file maintaining WordPress’s permalinks intact ?

    Read More
  2. How can I process the posts without having to create a pyramid of if statements and rather use WordPress’s own core functionalities ?

Related posts

Leave a Reply

1 comment

  1. Try looking at the code below and put your version of it in the functions.php file. This should work perfectly. You might have to replace the ‘ and ’ with apostrophes ‘.

    add_action(‘init’, ‘product_register’);
    
    function product_register() {
        $args = array(‘label’ => __(‘Products’), ‘singular_label’ => __(‘Product’), ‘public’ => true, ‘show_ui’ => true, ‘capability_type’ => ‘post’, ‘hierarchical’ => false, ‘rewrite’ => true, ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’));
    
        register_post_type(‘product’, $args);
    }
    add_action(“admin_init”, “admin_init”);
    add_action(‘save_post’, ‘save_price’);
    
    function admin_init() {
        add_meta_box(“prodInfo - meta”, “Product Options”, “meta_options”, “product”, “side”, “low”);
    }
    
    function meta_options() {
        global $post;
        $custom = get_post_custom($post - > ID);
        $price = $custom["price"][0];
        echo‘ < label > Price: < /label><input type=”text” name=”price” value=”‘. $price .’” / > ’;
    }
    
    function save_price() {
            global $post;
            update_post_meta($post - > ID, “price”, $_POST["price"]);
        }
        // custom table columns
    register_taxonomy(“catalog”, array(“product”), array(“hierarchical” => true, “label” => “Catalogs”, “singular_label” => “Catalog”, “rewrite” => true));