Skip to content

List overview: Pagination not working when Object Caching is enabled #101

@jmslbam

Description

@jmslbam

This cache will always be the same value of the first load:
https://github.com/samiahmedsiddiqui/custom-permalinks/blob/main/admin/class-custom-permalinks-post-types.php#L85

For example, this works, because it will take in account the page number where it's at.

// Takes $page_number in account for caching
$posts = wp_cache_get( 'post_type_results_' . $page_number, 'custom_permalinks' );

// Can't cache a search result
if ( isset( $_REQUEST['s'] ) && ! empty( $_REQUEST['s'] ) ) {
	$posts = false;
}

wp_cache_set( 'post_type_results_' . $page_number, $posts, 'custom_permalinks' );

Also take in account order scenario.

You want me to open a PR?

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions