1. Home
  2. ReHub Theme
  3. How to …
  4. How to add custom post type list in sidebar

How to add custom post type list in sidebar

If you enabled separate Blog post type in theme in Theme option – affiliate, you may need also to show list of latest blog posts in sidebar.

First of all, let’s create separate widget area for Blog. For this, install plugin Woosidebar

Go to Appearance – widget areas and create new widget area. Click on “Advanced” button and choose Blog type

By default, theme and wordpress widgets support only Posts, but not custom post types. To show such list, use Text widget and add next shortcode

[wpsm_recent_posts_list data_source="cpt" post_type="blog" image="1"]

THis will show latest posts from Blog Post type.

If you want to disable images and show only list, use

[wpsm_recent_posts_list data_source="cpt" post_type="blog"]

If you want to show only latest 5 posts, ue

[wpsm_recent_posts_list data_source="cpt" post_type="blog" show="5" image="1"]

If you need to show blog posts only from one category, for example, from category “best”

[wpsm_recent_posts_list data_source="cpt" post_type="blog" show="5" image="1" tax_name="blog_category" tax_slug="best"]

To show latest posts order by views, use

[wpsm_recent_posts_list data_source="cpt" post_type="blog" orderby="view" show="5" image="1"]


You can also use Rehub:Post list widget which supports custom post types.