• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Home
  • Blog
  • Sample Page

WordPress Tips

Just another WordPress site

Set a conditional argument for multiple Custom Post Types in WordPress

August 30, 2016 Leave a Comment

WP Beaches ~

You can set a conditional argument for multiple custom post types in WordPress using in_array

The format is like so…

if( in_array( get_post_type(), array(‘treatment’, ‘package’)) ) {//add in cpts here // do stuff } else {//what all the other post types get // do other  stuff } }

It searches the array of cpts to see if they belong

Filed Under: cpt, excerpt_more, in_array, PHP, WordPress Tagged With: cpt, excerpt_more, in_array, PHP, WordPress

Reader Interactions

Related Posts

  • Media Temple Managed WordPress Hosting: Overview and Review
  • Hotjar Heatmap Analytics: An Overview and Review
  • How to Use a Heatmap to Improve Your Website’s Overall Quality
  • GreenGeeks Eco-Friendly Hosting: An Overview and Review

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Copyright ©2019 · WPress.Tips - All Rights Are Reserved · Powered by Genesis Framework