2017-12-20 1 views
0

カスタム投稿タイプの検索フォームを作成しました。私は自分のサイトのどこにでも配置できるようにしたいので、ショートコードを作成しました。バニラフォームは正常に動作しますが、短いコードでは、重複フィールドが表示されます。それはなぜこれを行うだろう誰が見ることができますか?上位3つのフィールドは、下位フォームのフィールドと重複しています。結果はhttp://autismva.teebark.com/resource-finder-3にあります。フォームのショートコードで重複した入力フィールドが表示される

あなたは、私はこれがあなたのために働くことを願っていますhttp://autismva.teebark.com/resource-finder2

function resource_search_form($form) { 
$form = '<form id="category-select" class="category-select" method="post" action="' . esc_url(admin_url('admin-post.php')) . '" >' . 
    wp_dropdown_categories('show_count=1&hierarchical=1&depth=2&show_option_none=Select by category&name=$cat_id&taxonomy=resource_cat') . '<br>' . 
    wp_dropdown_categories('show_count=0&hierarchical=1&depth=1&show_option_none=Select by age&name=$age_id&taxonomy=resource_age') . '<br>' . 
    wp_dropdown_categories('show_count=0&exclude=128&show_option_none=Select by region&name=$region_id&taxonomy=resource_region') . '<br>' . 
    '<input type="text" name="s" placeholder="Search by keyword" /><br> 
    <input type="text" name="tag_name" placeholder="Search by tag" /> 
    <input type="hidden" name="action" value="resource_search_cat2" /> 
    <button type="submit" > Search </button> 
</form>'; 
return $form; 
} 

add_shortcode('resource_search', 'resource_search_form'); 

**The vanilla form:** 
<form id="category-select" class="category-select" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" > 
    <?php wp_dropdown_categories('show_count=1&hierarchical=1&depth=2&show_option_none=Select by category&name=$cat_id&taxonomy=resource_cat'); ?><br> 
    <?php wp_dropdown_categories('show_count=0&hierarchical=1&depth=1&show_option_none=Select by age&name=$age_id&taxonomy=resource_age'); ?><br> 
    <?php wp_dropdown_categories('show_count=0&exclude=128&show_option_none=Select by region&name=$region_id&taxonomy=resource_region'); ?><br> 
    <input type="text" name="s" placeholder="Search by keyword" /><br> 
    <input type="text" name="tag_name" placeholder="Search by tag" /> 
    <input type="hidden" name="action" value="resource_search_cat2" /> 
    <button type="submit" > Search </button> 
</form> 
+0

でこのアクションを記述します。関数が出力を返し、表示しないようにします。 – jh1711

+0

パーフェクト - ありがとうございます。 – teebark

答えて

0

でバニラの形を見ることができます。あなたはショート以内にそれを使用するときにwp_dropdown_categories` `に`エコー= false`をを渡す必要が私の知る限り は//あなたの「after_setup_theme」フック

add_action(' woocommerce_single_product_summary ' , ' your_function_name ' , 10); 

//define your function that contains the removal action hook. 
function your_function_name() 
{ 
    remove_action(' woocommerce_single_product_summary ' , ' woocommerce_template_single_add_to_cart ' , 30); 
} 
関連する問題