Complete the code to add a caching plugin in WordPress to improve performance.
add_action('[1]', 'wp_cache_set');
The template_redirect hook is used to add caching before the page loads, improving performance and user experience.
Complete the code to enqueue a minified CSS file for faster loading in WordPress.
wp_enqueue_style('theme-style', get_template_directory_uri() . '/style[1].css');
Using .min in the filename is the standard for minified CSS files, which load faster and improve user experience.
Fix the error in the code to defer JavaScript loading for better performance.
function defer_scripts($tag, $handle) {
if ($handle === '[1]') {
return str_replace(' src', ' defer src', $tag);
}
return $tag;
}
add_filter('script_loader_tag', 'defer_scripts', 10, 2);The script handle main-js is the correct one to defer loading for the main JavaScript file, improving page load speed.
Fill both blanks to create a function that limits post revisions to improve database performance.
function limit_revisions([1]) { return [2]; } add_filter('wp_revisions_to_keep', 'limit_revisions');
The function takes $num as input and returns 3 to limit revisions to three, reducing database size and improving performance.
Fill all three blanks to register a custom image size and enable it in WordPress theme.
add_image_size('[1]', [2], [3], true); add_filter('image_size_names_choose', function($sizes) { return array_merge($sizes, ['[1]' => 'Custom Size']); });
The custom image size named custom-thumb with width and height 150 pixels is registered and added to the media selector for better performance and user experience.