To get a list of selectable categories use wp_dropdown_categories()
.
Example:
wp_dropdown_categories(
array (
'orderby' => 'name',
// ID of the already selected category:
'selected' => 4,
// If no category is selected:
'show_option_none' => 'Choose one'
)
);
HTML output:
<select name="cat" id='cat' class="postform" >
<option value="-1">Choose one</option>
<option class="level-0" value="4" selected="selected">Animals</option>
<option class="level-0" value="6">Hyperbolica</option>
<option class="level-0" value="5">Nonsense</option>
<option class="level-0" value="1">Uncategorized</option>
</select>
Visual output:
Related Posts:
- How to divide and display categories into two columns
- Output categories in something different than a list
- How do I append lists in Prolog?
- Inorder Binary Tree Traversal (using Python)
- How to have a set of sets in Python?
- Learning Haskell: How to remove an item from a List in Haskell
- How to obtain a subarray in python 3
- Reversing a List in Prolog
- List Length in Prolog
- Display list of Sub-Categories and the posts they contain, within one main Category
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Categories list loop – add separator every year
- Exclude a category from the filed under list only on some templates
- Listing all posts from current category on page
- Display only one result from “get_the_category_list”
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Editing a Post, 99% CPU?
- Similar posts formatting
- How to find the number of Tags a post has?
- Get woocommerce catogry
- wordpress wp_list_categories
- wp_dropdown_categories and custom taxonomy + custom post type
- Get all sub-categories of a parent category
- Introductory paragraph only in list of blog posts
- Check child/parent categories if exists
- Show Available Taxonomy List with Current Category
- WooCommerce Grid / List view
- custom walker wp menu last element
- Display the last post by each category?
- To get list of bottom most or deepest or last child for specified parent category
- List all categories with featured image from post?
- List categories with custom code
- limit a list of tags to one category [closed]
- Categories list loop – add separator every 3 categories [closed]
- how to wordpress When I click on the category link, subcategories appear
- new WP_Query all post in a category inside the loop
- get listed category’s id?
- List Child Categorie and hide the parent
- Adding category dropdown list to theme options page
- Hide specific category from wp_list_categories
- How do I add a separator to my list of terms with get_category
- How to show a list of only categories (exclude subcategories)
- Category list with postcount
- List first letter of categories – issue upon spcecial characters (danish letters)
- How do I create an alphabetically organized glossary of links?
- Highlighting Current Category in the Archive and Feeds page
- Generate a nested list of all posts, sorted first by year, then by month
- adding a #hash to each link in list_pages()?
- Getting the posts list visualised in categories tree
- display the months of a specific category
- Return all Tags and Categories in Separate List
- get taxonomy list in a page in the wordpress
- List all taxonomies with their descriptions
- How correct list-style displayed in firefox? [closed]
- How Can Hide Define Category in Post Contents?
- AZ Directory category
- Search tag within category
- Wrap Meta Box with and for each new line
- Listing category
- get_all_category_ids for bookmark
- Add thumbnails in ‘li’ list
- List products from current category
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- List posts that are in the same category as the current post title
- list taxonomy based on taxonomy
- List child pages alphabetically
- How to make a text string into a bullet list [closed]
- How to display my categories in a list (to a post, not the sidebar)?
- Moving Blog and Changing URL
- Difference between del, remove, and pop on lists
- Linq select objects in list where exists IN (A,B,C)
- Get Default Post Category From Settings
- Create subdomains for tags and categories
- Categories and Tags not working!
- How do I count how many top level categories there are?
- display most popular tags of category?
- Exclude category from loop not working
- category.php displays ALL posts instead of just those with the current category
- Display Next/Prev when looping Custom post-types archive?
- How to set up multiple taxonomies for groups of posts
- Show Different Custom Menu on Different Category Pages
- Category Thumbnail Display – How to display ONLY the main Category
- Hide woocommerce category name from specific pages
- category permalinks
- Displaying Child Categories in carousel
- Is there an easy way to get a list of Category IDs?
- post category in wp_insert_post
- View the complete list of a taxonomy in the navigation menu
- Display data when category is empty
- Mutliple users editing single document in wordspress
- Media (images, videos, etc.) not showing on Category page
- Displaying categories in different template problem
- create a “add icon” field in taxonomies page
- How to filter specific element of an array in wordpress/php?
- i can’t use wordpress functions in ajax loaded php file
- Multiple values in WP_Query : category__and
- show posts found in multiple categories via category_name query string?
- Display last postings of 5 categories on homepage
- How to add the sidebar in all category page
- Images as Categories