WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Nav items cached in preload (1 post)

  1. Inposure
    Member
    Posted 3 years ago #

    In wp-cache.php, on line 2390, you select all ID from the table posts where post_status is "publish" when caching in preload mode:

    $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT $c, 100" );

    Thing is, not all items where post_status is "published" are of post_type = "post", but also of post_type = "nav_menu_item".

    Caching nav_menu_item will generate a 404 error and slow things down. post_name for nav_menu_item is always the same as ID, that is a number.

    To solve this, WP Super Cache must also check that post_type = "post" in its SQL statement:

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

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic