WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Preload Custom Post Types ? (6 posts)

  1. Adam Capriola
    Member
    Posted 2 years ago #

    Is there any way to preload custom post types? I've noticed that only posts and pages are preloaded by default.

    A suggestion for a future release might be to use your site's sitemap to determine preload order via priorities.

    But awesome plugin regardless! :)

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Nope, no way right now but if you'd like to modify the preload code I'll gladly accept a patch!

  3. Adam Capriola
    Member
    Posted 2 years ago #

    Here's my edit...

    In wp-cache.php I changed line 2505 (or thereabouts) from:

    if ( $wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts ) {
    		$posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE
    (post_type = 'post' OR post_type='page') AND post_status = 'publish' ORDER BY
    post_date DESC LIMIT $c, 100" );

    to

    if ( $wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts ) {
    		$posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE
    (post_type = 'post' OR post_type='page' OR post_type='MY_POST_TYPE') AND
    post_status = 'publish' ORDER BY post_date DESC LIMIT $c, 100" );

    Basically I all I did was add OR post_type='MY_POST_TYPE'. I'm honestly not sure if it worked or not, but I think that's right!

  4. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Yeah, that'll work for your custom post type. The problem is adding that as a variable on a settings page. I could try filtering out things that are NOT to be cached - like inherited records and others but I'm 100% positive that will cause problems for someone else. :(

  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    I just updated the development version so it grabs every post EXCEPT FOR revisions and nav menu items. Can you give the development version on the download page a go?

  6. Adam Capriola
    Member
    Posted 2 years ago #

    Sure thing, just installed it. Hopefully it works! :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic