working on a highly complex WordPress theme that features many different custom post types. I was under the impression that the following code would check to see if the current post was of the type "philosopher" and then run the PHP conditional that follows it only if the post is in that type:
<?php if (get_post_type() == 'philosopher') { ?>
Unfortunately, my expectation was that to make the same item conditional for "philosopher", "text", and "original" my code should look like this:
<?php if (get_post_type() == 'philosopher','text','original') { ?>
But alas, I was wrong. I did get the following code to work, but I'm wondering if there's a cleaner way to do this (or if I'm somehow missing something)
<?php if ( (get_post_type() == 'philosimply') || (get_post_type() == 'text') || (get_post_type() == 'original')) { ?>
if ( in_array(get_post_type(), array('philosopher','text','original')) ){ ... }
http://www.php.net/manual/en/function.in-array.php
Is that, what you are looking for?
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With