0

Hello every i am new to wordpress. I want to make my own widget which have a category selection option on backed and able to display posts from selected category on front.

  • Welcome to WPSE. If you do a quick search you'll find there are already plugins that do exactly that. Or, do a quick search to find out how to build it yourself, and you can then include it in your theme if you like, instead of having a separate plugin. :) – WebElaine Jun 20 '17 at 19:15
  • I search lot for it on stack and google but could not find i want to code for myself without using plugin – Muhammad Ibrahim Jun 20 '17 at 19:17
1

I'd start with a basic widget tutorial.

From there, I'd add a dropdown on the widget back end that lists out all the categories, so you can select from existing categories.

Then on the widget front end, I'd do a WP_Query to pull a specific number of posts from that category. With posts selected, do a foreach loop to display the <li> with link and title. Depending on your scenario, you might also want to allow the admin to choose that limited number in the widget back end, or you might just want to hard-code it to show, say, 7 posts at maximum.

Give it a try and then if you're having specific issues post your code as an edit to the original question for a bit more guidance.

  • Can you share github link – Muhammad Ibrahim Jun 20 '17 at 19:30
  • 1
    If you don't want to use an existing plugin, sometimes you have to roll up your sleeves and dig in yourself. :) – WebElaine Jun 20 '17 at 19:31
  • Haha thanks but i cant understand a form section while creating widget – Muhammad Ibrahim Jun 20 '17 at 19:33

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.