Support » Themes and Templates » Select category from dropdown, display random post from that category

  • Hey folks. Was wondering if anyone could recommend a good way to display a single, random post from a wp_dropdown_categories() menu. Basically, I have a custom post type called Tips and a taxonomy term called Tip Categories. I want to display the Tip Categories in a dropdown (which I have done already using wp_dropdown_categories), then when a user selects a Tip Category and clicks a submit button, a random tip from that category will display.

    I suppose I can figure out a way to do this on the front end with Javascript/CSS (generating all tips, then showing/hiding them) but it seems like it would be best to generate one tip and do it all in PHP. Anyone have an idea of how best to accomplish this? Can I somehow pass the value of the wp_dropdown_categories selection to WP_Query()? Maybe this is easier than I thought and I’m missing something?

    Thanks in advance.


  • The topic ‘Select category from dropdown, display random post from that category’ is closed to new replies.