Custom posttype in homepage loop


/ Published in: PHP
Save to your folder(s)

Add 'demo" posttype in main loop and also in the RSS feed


Copy this code and paste it in your HTML
  1. function custom_posttype_in_home_loop($query)
  2. {
  3. if (is_home() && $query->is_main_query() || is_feed())
  4. $query->set('post_type', array('post', 'demo'));
  5. return $query;
  6. }
  7.  
  8. add_filter('pre_get_posts', 'custom_posttype_in_home_loop');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.