带表单的短代码显示重复的输入字段

问题描述 投票:0回答:1

我为自定义帖子类型创建了一个搜索表单,我希望能够将它放在我的网站上的任何位置,因此我创建了一个短代码。香草形式工作正常,但在短代码中,它显示重复的字段。任何人都可以看到为什么会这样做?前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>
php html wordpress forms shortcode
1个回答
0
投票

我希望这对你有用。 //在“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 );
}
© www.soinside.com 2019 - 2024. All rights reserved.