3

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

3

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.)

0

You appear to be missing a parenthesis. Try:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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