Reputation: 11
I have created a new post type for testimonials and portfolio. I have created new widget areas,with this
register_sidebar( array( 'name' => __( 'Testimonial Sidebar', 'my-theme' ), 'description' => __( 'Testimonial widgets area', 'my-theme' ), 'id' => 'sidebar-3', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', ) );
I have created page sidebar-testimonial.php
and call them in single-testimonial.php
by get_sidebar('testimonial');
Now my question is, how to create the widget "Recent Testimonials" same as "Recent Post", by dragging it in 'Testimonial sidebar' I can display them in pages.
Upvotes: 0
Views: 243
Reputation: 9941
It is real easy to create your own recent post widget.
Here are the steps:
Copy the default recent posts widget from core which can be found here.
Add all the relevant code for the widget in your functions.php and rename the widget to what ever you like
Register the new widget. You will now see the widget in the backend
Final customization here would be to alter the query inside the widget. All you basically need to do is to add 'post_type' => 'YOUR POST TYPE NAME',
to your query arguments on line 702 of the link provided above
YOu can alternatively make use of the filter provided and simply just filter the arguments of the default recent post widget
Upvotes: 0