wp_dropdown_categories and custom taxonomy + custom post type

You can get your code to work the expected way by adding the following three arguments to your $args array which you pass to wp_dropdown_categories():

  • name — the select name as in <select name="<here>">, and you should set it to theme which is your custom taxonomy slug.

  • value_field — the value of the <option>‘s in that select dropdown, e.g. <option value="<here>">.

    And you should set the arg to slug so that when the form is submitted (or when a term is selected), the browser would go to https://example.com/?theme=term-slug-here and then WordPress redirects the browser to the correct term permalink if (and it’s commonly) enabled.

  • selected — the selected option which is a term in the custom theme taxonomy and because the form’s destination is the term archive page, and that a term slug was specified (see the sample URL above), then set this arg to get_query_var( 'theme' ) to get the slug of the term being queried on the page.

So try with:

$args = array(
    'show_option_all' => __( 'Choose theme', 'l-p' ),
    'hide_empty'      => 0,
    'echo'            => 0,
    'show_count'      => 0,
    'taxonomy'        => 'theme',

    // Add these three args:
    'name'            => 'theme', // same as the "taxonomy" above
    'value_field'     => 'slug',  // use the term slug
    'selected'        => get_query_var( 'theme' ),
);