Wordpress Conditional statement for Singular Custom Post Type


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

Suppose you wanted to check if a user was viewing a singular post with the post type of testimonial. You can use the next code sample to perform this check.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. if ( is_singular( 'testimonial' ) ) {
  4.  
  5. /* Run some code if viewing a singular testimonial. */
  6. }
  7.  
  8. ?>

URL: http://justintadlock.com/archives/2011/07/20/conditional-checks-for-custom-post-types

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.