Hi,
centumcellae.it uses wp 5.5.1 latest version of newspaper and all plugins are updated. It is an online magazine and has almost 70,000 posts (select count (*) from wp_post returns 69,700 or something like that)
It happens that when you publish, or to be more precise, a few seconds later in particular sometimes for several minutes the site is very slow both in the front end and in the back end and we see that there are from 4 to more than twenty sometimes queries as below
SELECT SQL_CALC_FOUND_ROWS wp_posts. *, wp_sticky.sticky_status
I don’t know if it depends on wp fastest cache (which deletes the cache after i publish a new post) or if it depends on newspaper (maybe it’s too heavy?).
the fact is that we added the code below to the functions.php which gives rise to a critical error of wp. How can I solve? Help! Thank you very much
if ( ! function_exists( ‘wpartisan_set_no_found_rows’ ) ) :
/**
* Sets the ‘no_found_rows’ param to true.
*
* In the WP_Query class this stops the use of SQL_CALC_FOUND_ROWS in the
* MySql query it generates. It’s slow so we’re going to replace it with
* a COUNT(*) instead.
*
* @param WP_Query $wp_query The WP_Query instance. Passed by reference.
* @return void
*/
function wpartisan_set_no_found_rows( \WP_Query $wp_query ) {
$wp_query->set( ‘no_found_rows’, true );
}
endif;
add_filter( ‘pre_get_posts’, ‘wpartisan_set_no_found_rows’, 10, 1 );
if ( ! function_exists( ‘wpartisan_set_found_posts’ ) ) :
/**
* Workout the pagination values.
*
* Uses the query parts to run a custom count(*) query against the database
* then constructs and sets the pagination results for this wp_query.
*
* @param array $clauses Array of clauses that make up the SQL query.
* @param WP_Query $wp_query The WP_Query instance. Passed by reference.
* @return array
*/
function wpartisan_set_found_posts( $clauses, \WP_Query $wp_query ) {
// Don’t proceed if it’s a singular page.
if ( $wp_query->is_singular() ) {
return $clauses;
}
global $wpdb;
// Check if they’re set.
$where = isset( $clauses[ ‘where’ ] ) ? $clauses[ ‘where’ ] : ”;
$join = isset( $clauses[ ‘join’ ] ) ? $clauses[ ‘join’ ] : ”;
$distinct = isset( $clauses[ ‘distinct’ ] ) ? $clauses[ ‘distinct’ ] : ”;
// Construct and run the query. Set the result as the ‘found_posts’
// param on the main query we want to run.
$wp_query->found_posts = $wpdb->get_var( “SELECT $distinct COUNT(*) FROM {$wpdb->posts} $join WHERE 1=1 $where” );
// Work out how many posts per page there should be.
$posts_per_page = ( ! empty( $wp_query->query_vars[‘posts_per_page’] ) ? absint( $wp_query->query_vars[‘posts_per_page’] ) : absint( get_option( ‘posts_per_page’ ) ) );
// Set the max_num_pages.
$wp_query->max_num_pages = ceil( $wp_query->found_posts / $posts_per_page );
// Return the $clauses so the main query can run.
return $clauses;
}
endif;
add_filter( ‘posts_clauses’, ‘wpartisan_set_found_posts’, 10, 2 );
WP 5.5.1
PLUGINS
AddToAny Share Buttons
AdRotate
Advanced Ads
BestWebSoft’s Like & Share
Custom Sidebars
Disable Gutenberg
Duplica pagina
Embed Plus for YouTube – Gallery, Channel, Playlist, Live Stream
Google XML Sitemaps
Jetpack by WordPress.com
ONE SIGNAL
Re-Add Text Justify Button
Really Simple SSL
Responsive Like Box
Restrict Categories
Simple YouTube Responsive
tagDiv Cloud Library
tagDiv Composer
tagDiv Newsletter
tagDiv Social Counter
tagDiv Standard Pack
the_excerpt Reloaded
Widget for Social Page Feeds
Wordfence Security
WP Migrate DB
wp fastest cache
WP-Sticky
YouTube Embed WpDevArt
PHP 7.4
wp 5.5.1
Server info
S.O. Linux webxc302s03.ad.aruba.it 3.10.0-862.2.3.el7.x86_64 # 1 SMP Wed May 9 18:05:47 UTC 2018 x86_64
Apache webserver
Php 7.4.8
MySQL 5.5.62-38.14-log
Hello !
The page speed of your website depends on how well your site is optimized, if you follow the steps which are presented in this tutorial here -> https://tagdiv.com/how-to-increase-page-loading-speed/ you’ll be able to increase the speed of your website.
Also you can check this similar topic for more solutions: -> https://forum.tagdiv.com/topic/optimize-script-to-improve-site-speed/ -> https://www.infophilic.com/get-almost-100-pagespeed-newspaper-theme/
– https://forum.tagdiv.com/topic/a-few-tips-for-newspaper-x-speed-high-cpu-usage-issues/
– https://tagdiv.com/how-to-increase-page-loading-speed/
Please note that page speed is not covered by the support team: https://forum.tagdiv.com/newspaper-theme-support/
For page speed and other services you can contact our custom work team here: https://tagdiv.com/premium-customization-services/
Hope this will help you!
Thank you !