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. 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.

Was this article helpful to you? Yes No

How can we help?