• Resolved Quintinm

    (@quintinm)


    Hello.
    I have created tutorials CPT which is working correctly.
    I added a category “Tutorials” and assumed it would show up in the sidebar when I selected “Tutorials” for display.
    But it does not.
    Is there something I am doing wrong – do I need a special recent posts widget?

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    By default, the widget only queries for the “post” post type and I don’t think they provide any UI to change that. They do however provide a filter to change the arguments used. So, something like this below should help you out, once you add your intended post type slugs to the array:

    /**
     * Add CPTs to recent posts widget
     *
     * @param array $args default widget args.
     * @return array $args filtered args.
     */
    function quintinm_recent_posts_args($args) {
        $args['post_type'] = array('post', 'MY SLUG HERE');
        return $args;
    }
    add_filter( 'widget_posts_args', 'quintinm_recent_posts_args');
    

    Just drop this into your functions.php file for your active theme and give things a try.

    Thre is a plugin called “Custom Post Widgets” that will add widgets that will do exactly what you are looking for (for posts, comments, archives, calendar, etc …) here is a link: Custom Post Widgets Website … and it works just fine for me under the current version of WordPress.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Link’s not working there but good to know in general

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do i display the CPT in a recent posts sidebar.’ is closed to new replies.