WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default gallery on the "listings' page?

I have this code in my functions.php, and I can't seem to get the reference right for the custom post type:

function add_gpp_gallery() {
    if( ( is_single() || is_page() ) && ( !is_page_template('page-blog.php') ) ){
        remove_shortcode('gallery', 'gallery_shortcode');
        add_shortcode('gallery', 'gpp_gallery_shortcode');

above is the code the plugin uses, and I added it to my functions.php and tried this change:

if (is_single() && is_post_type('post_type'){

and that returns an error.

thoughts & thanks

share|improve this question
up vote 3 down vote accepted

Try using get_post_type() instead:

if ( is_single() && 'post_type' == get_post_type() ) {
    // Do something

The is_post_type() conditional is deprecated. But even when it existed, it returned true if the current post is any registered custom post type. It has been replaced with post_type_exists().

(More information on Post Type conditional tags.)

share|improve this answer

You appear to be missing a parenthesis. Try:

if (is_single() && is_post_type('post_type')) {
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.