• Resolved weltonwang88

    (@weltonwang88)


    For my website, I want to only preload a specific post type, because some of the other post types are not viewed by users and are for technical purposes only. It is a huge waste to load every single post type. If there some setting or php code to only limit preloading to a post type?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • WPSC preloads only public post types. It’s better to remove public flag if you can (because they are not viewed by users). Selection of post types isn’t possible by setting but it’s possible to use filter wpsc_preload_post_types which returns array of post types which are preloading.
    Do you need exact PHP code?

    Thread Starter weltonwang88

    (@weltonwang88)

    Yes please, thanks!

    If you want to exclude a post type, then you could use this filter and unset function:

    add_filter( 'wpsc_preload_post_types', 'my_wpsc_preload_posts' );
    function my_wpsc_preload_posts( $post_types ) {
       unset( $post_types['question'] );
       return $post_types;
    }
    

    If you want to preload only couple post types, then you could use this snippet:

    add_filter( 'wpsc_preload_post_types', 'my_wpsc_preload_posts' );
    function my_wpsc_preload_posts( $post_types ) {
       return array( 'page', 'post', 'question' );
    }
    
    Thread Starter weltonwang88

    (@weltonwang88)

    Thank you soo much! It worked!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Preload only a post type’ is closed to new replies.