0

私はyootheme proのテーマフォームを持っており、searchform.phpに以下のコードがあります:

<?php
/**
 * The template for displaying a search form.
 */

$result = get_view('search', [

    'position' => get_current_sidebar(),
    'attrs' => [

        'id' => 'search-'.rand(100, 999),
        'action' => esc_url(home_url('/')),
        'method' => 'get',
        'role' => 'search',
        'class' => '',

    ],
    'fields' => [

        ['tag' => 'input', 'name' => 's', 'placeholder' => esc_attr_x('Search &hellip;', 'placeholder'), 'value' => get_search_query()], 'name' => get_post_type()]

    ]

]);

if ($echo) {
    echo $result;
} else {
    return $result;
}

このコードを変更して、結果の URL に &post_type=product を追加することにしました。

ありがとう

4

1 に答える 1