0

Im using wp_dropdown_categories for a page. Issue im having is i dont want it to show the current category that the page is on as the title, i want it always to display the "Select A Category" text i have placed in the options. Current code is:

wp_dropdown_categories( 'show_option_none=Select A Category&show_count=1');

Is there a way to do this?

1

You can use get_query_var( ) to fetch the current category:

$cat = get_query_var( 'cat' );

You can use this $cat in the exclude parameter of wp_dropdown_categories( ) to hide the current category:

$args = array(
  'show_option_none' => __( 'Select A Category' ),
  'show_count' => 1,
  'exclude' => $cat
);

wp_dropdown_categories( $args );
0

Try using the exclude parameter.

wp_dropdown_categories('show_option_none=Select A Category&show_count=1&exclude=45');

Where 45 is your current category ID.

  • This will not work for the situation. Please read the question. – Noob Theory Jun 13 '13 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.