Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

add_action('wp_head','add_gpp_gallery');
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
add comment

2 Answers 2

up vote 2 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
add comment

You appear to be missing a parenthesis. Try:

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

Your Answer

 
discard

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.