It looks like you are trying to model this on theme options code. You can’t do that. That is backend code. As written, this question is very broad– I am tempted to vote to close as “too broad”– but I will offer bare bones code to get you started:
echo '<form method="post">';
wp_dropdown_categories();
echo '<input type="submit" name="catsearch" value="Submit" />';
echo '</form>';
if (isset($_GET['cat']) && ctype_digit($_GET['cat'])) {
$qry = new WP_Query(
array(
'cat' => (int)$_GET['cat']
)
);
var_dump($qry);
}
You will need to consult the documentation for wp_dropdown_categories
and WP_Query
, and will probably need to do a bit a research on HTML forms and basic PHP.
Related Posts:
- Plugin for custom sort order for categories?
- Posts in multiple Categories different single.php
- Append HTML to an LI of wp_list_categories
- get_query_var() and permalinks
- Highlight “Show all” item in wp_list_categories
- Apply different Class for each element in a foreach()
- Category specific themes?
- filter “inactive” categories from wp_list_categories?
- How to get category lists by name or slug
- the_category() tag not styling HTML or CSS
- How to custom category template based on category?
- 1 post per category on homepage and counting those posts
- List categories of a post hierarchically?
- Exclude parent categories from the_category() within the loop
- Archives and Categories in Custom Menu
- How to show some of category in wordpress
- Breaking Categories Up into Individual Divs
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- Worthwhile to restrict direct access of theme files?
- How Do I Protect My Premium WordPress App Theme from Copying?
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to add posts to custom menus?
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- What is the difference between front-page.php and home.php? [duplicate]
- How can I get page slug
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- When to use _e and __ for the translation?
- What is a Theme textdomain?
- How to show a custom meta box on the “Quick Edit” screen?
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- CSS not updating in browser when I change it
- Display Search Result Count
- wp_nav_menu(), how to change class?
- theme path in javascript file
- Is wp_is_mobile() effective?
- Display Menu Name using wp_nav_menu
- Making update notification functionality for my themes
- What questions do you ask when asked to give an estimate on theme development?
- How to remove dashicons.min.css from frontend?
- How do I remove a pre-existing customizer setting?
- Minimum Template Files for Theme Development
- What’s the difference between home.php and index.php?
- pass object/JSON to wp_localize_script
- get_template_part vs action hooks in themes
- Theme Activate Hook
- Solutions for generating dynamic javascript / CSS
- wp_redirect() – headers already sent
- Can I create my own “Recent Posts” widget or customize the existing one?
- Custom single template for a specific category
- how can I add an icon/image for a child theme?
- How can I add a URL field to the attachments window?
- The the_post_thumbnail without srcset?
- The proper way to include/require PHP files in WordPress
- Get the first image from post content (eg.: hotlinked images)
- after_setup_theme always runs
- When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
- Getting failure when using filemtime() with wp_enqueue_style
- Do I actually need to link my theme’s style.css in the theme files
- Why is wp_head() creating a top margin at the top of my theme header?
- How to store widget fields data as an array?
- How do I add version control to my workflow?
- Using classes instead of global functions in functions.php
- WordPress API Menu/Submenu Order
- How can I display a menu on certain pages only?
- Enqueue a stylesheet for login page and make it appear in head element
- Adding a div to wrap widget content after the widget title
- How to insert a logo in the header?
- How to set permalink structure via functions.php
- What is $post_id? is it a global variable in WordPress?
- How to override pluggable function in theme?
- How to move page template files like page-{slug}.php to a sub-directory?
- WooCommerce shop page to use my custom template [closed]
- Theme customizer – settings order
- What is the difference between wp_register_sidebar_widget and register_widget?
- Should we use get_template_part() in functions files instead of include_once?
- Reset positions of metaboxes in admin
- CSS classes for theme
- “Quick Edit” > update clears out my custom meta values
- How to enqueue script if widget is displayed on page?
- Custom Image section in Customizer
- A way to automatically install pages on theme install?
- Get entered value of customiser field for live preview
- Add custom classes to anchor in wp_nav_menu
- How to remove search bar from a wordpress theme? [closed]
- Upgrade from 5.0.4 to 5.1.1 causes $theme to be null
- Bestway To Define Theme and Plugin path and url