You’re going to want to use AJAX for this. WordPress provides resources for connecting JS to PHP callbacks which is outlined in detail in the Codex. Basically, you’ll want to take the following steps:
- Attach a handler to the first category select box using the .change() jQuery method.
- Use an AJAX function to post that data to the ajax url to call your PHP callback function.
- Create a PHP callback function that will take the category name from the select box and use WP_Query to retrieve a list of posts, which the function will then
return
to the AJAX function. - Take the server response back in the JS ajax function and use it to set the select values of the second select box in the widget using jQuery.
It sounds like you’ve already figured out the complexity of the Widgets API so this should be a walk in the park for you.
Related Posts:
- How Can I Add the “Insert From URL” Tab to a Custom 3.5 Media Uploader?
- Where is the content of widgets stored in mysql table
- How to refresh Theme Customizer after change color inside wpColorPicker?
- How to Remove All Widgets from Dashboard?
- Determining a Widget Instance and Sidebar Location?
- Randomize widgets displayed in my sidebar [duplicate]
- Calling static method in the Widget Class
- Remove […] from RSS feed?
- What is the best way to include a widget in a Page?
- How to create a widget that has a submit form in the front end
- Custom shortcode in widget forced to top of widget
- Modifying recent post widget to include icons for post titles
- Unfiltered html in widget title not working
- How to process content in a widget? [duplicate]
- How to retrive widget title/data
- Separate backend “Widgets” page for each language
- How Can I Register Menus and Widgets Conditionally Based on Theme Options/Settings?
- How do I embed in a text widget?
- Where (what direcory) are the default WordPress Widget Codes stored?
- Why use dynamic_sidebar() conditionally?
- WordPress Widget multiple use
- Contact Form in sidebar [closed]
- Display the date before the post title in recent posts widget
- Closest thing to an is_widget() tag?
- More flexible sidebar and widget management
- Why won’t my custom widget stay in the sidebar after a reload?
- How to “pair” two widgets side by side in one sidebar [closed]
- Dynamic Sidebars On Multiple Subpages
- Can I remove a widget area without editing code?
- Custom dashboard widget search box
- Cannot save widgets in custom sidebars
- Disable widgets on specific posts
- Font awesome Icon HTML in widgets disappear on save
- How to determine the number of widgets contained in a sidebar via customizer JS
- WordPress Plugins won’t save
- Hide widget if user is logged in without plugin
- Toggle option in sidebar widgets
- for class wp_widget, in what order are the member functions called?
- Add field to dashboard to update embedded URL on homepage?
- unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)’ in widget [closed]
- styling back end widget form and enabling multi widget feature
- How to show different widgets on different pages in a user friendly way
- widgetlogic and permalinks
- allow user to style widget backgound per widget
- I’m trying to find a basic plugin for displaying images in a widget [closed]
- A form in a custom widget
- Block-based Widgets Editor – how to enable a title
- Widgets in home.php redirect to index.php
- How to make a can’t hide widget?
- How to track whether the user has changed the value of the field in the widget or not?
- WordPress: How to embed a widget on a separate website?
- Widget on the right side of the page overlaps with the left side [closed]
- Making tags appear as an Unordered list instead of a ‘cloud’
- Shortcode not working in widget
- How to get options of all active widgets ?
- How to use the widget area to extend the page content?
- wordpress widget missing jquery
- Display a widget on a specific type of archive
- Add a specific css to a widget
- Widget Title is not saving in backend
- Add class to on sidebar widget
- Save button is not working on custom widget
- WordPress update not saving
- WordPress Edit Button not appearing for widget in customizer
- WordPress database error – quick review
- Select two value from meta key and post meta
- Removing widget from home page when coming from specific landing page
- How do I insert an amazon search widget into posts or pages?
- How to remove Help tab and the Dashboard widget area’s empty border
- Check if widget is inside sidebar with PHP
- latest posts-widget displays all posts on archive page but works great anywhere else
- Widget : html 2 dimensional array doesn’t work
- call widget from within shortcode
- How to get class from widget area
- In widget, the value of select field doesn’t get updated, changes after saving
- Removing widget without using unregister_widget
- Editing Help Section
- SELECT field options disappear when saving widget
- WordPress text filed input only inter value?
- Need to delete the sidebar widget area and have the page a full page rather than just have a blank widget area
- Display Login user name in Thim:login Popup widget
- Searching for a one page overview widget
- WP renders HTML wrong when adding widgets
- How do I add after the tag in WordPress widget?
- Creating a simple button inside of a widget
- The WP_Widget class seems to run many times on a page load
- How to check widget-cpt meta and display its custom css in the head?
- How to add WooCommerce Add to Cart button in widget?
- How to call theme default widget in custom template?
- How to place a widget beside a div/text so that they display as a continuous line
- Widget Logic code for different PMP membership levels
- How to Activate WordPress Widgets
- WordPress wiget admin panel
- Filter “widget_comments_args” won’t work
- How to output built-in widgets with number in range as class?
- How to create a widget on witch a registered user can create a checklist
- How to hide sidebar widgets in all pages except Hompage?
- How can I create my own widgets in WordPress? [closed]
- Can’t edit the widgets sidebar or footer
- Custom dashboard widget – load style only for added widget