-
Good Morning,
I was having a CPU issue and traced it back to Rank Math. I am getting 9 critical errors. Here are screenshots:
https://www.f9finance.com/wp-content/uploads/2024/11/Rank-Math-Error-1.jpg
https://www.f9finance.com/wp-content/uploads/2024/11/Rank-Math-Error-2.jpg
Thank you for your assistance.
Cheers,
Mike
-
Hello,
We apologize for the issue you are facing with Rank Math causing CPU overage and critical errors. Thank you for providing the screenshots; they will be helpful in diagnosing the problem.
To address the CPU issue, it’s important to check if there are any conflicts with other plugins or themes. Additionally, ensure that your website is running the latest version of Rank Math and that all other plugins are updated as well.
If the problem persists, we recommend checking the following:
- Check for Plugin Conflicts: Deactivate other plugins one by one to see if the issue resolves.
- Server Resources: Ensure your hosting plan has sufficient resources to handle your website’s traffic and operations.
- Caching: Implement caching solutions to reduce server load.
If you continue to experience these errors, please reply to this ticket, and a human agent from the Rank Math Support team will take over and assist you further.
Thank you for your patience, and we look forward to resolving this issue for you!
Hello,
Thank you for contacting support.
The error is present in the
functions.phpfile of your child theme. Please share the custom code from that file so we can check what custom Rank Math filters you have added there and advise further.Looking forward to hearing back from you.
// BEGIN ENQUEUE PARENT ACTION // AUTO GENERATED - Do not modify or remove comment markers above or below: if ( !function_exists( 'chld_thm_cfg_locale_css' ) ): function chld_thm_cfg_locale_css( $uri ){ if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) ) $uri = get_template_directory_uri() . '/rtl.css'; return $uri; } endif; add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' ); if ( !function_exists( 'child_theme_configurator_css' ) ): function child_theme_configurator_css() { wp_enqueue_style( 'chld_thm_cfg_child', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css', array( ) ); } endif; add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css', 10 ); // END ENQUEUE PARENT ACTION //custom schema //publishing principles add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { if ( isset( $data['publisher'] ) ) { $data['publisher']['publishingPrinciples'] = ['https://www.f9finance.com/editorial-guidelines/']; } return $data; }, 99, 2 ); /** * This code is responsible for registering custom variables that can be used in Rank Math SEO settings or templates. These variables provide additional information about authors and reviewers associated with post */ /* add_action calls, each registering a custom variable replacement using the rank_math_register_var_replacement function. */ add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'author_knowsabout', [ 'name' => esc_html__('Author Knowns About', 'rank-math'), 'description' => esc_html__('Author Knowns About Info', 'rank-math'), 'variable' => 'author_knowsabout', 'example' => author_knowabout_callback(), ], 'author_knowabout_callback' ); }); /* For each custom variable, there is a corresponding function that is called to retrieve the desired information. These functions are named using a consistent pattern, such as author_knowabout_callback The functions use the WordPress functions and the Advanced Custom Fields (ACF) plugin to retrieve specific information about authors and reviewers. The get_field function is used to retrieve field values associated with the author's or reviewer's user profile. */ function author_knowabout_callback() { global $post; $author_id = $post->post_author; $author_info1 = get_field('author_knowabout', 'user_'. $author_id ); $author_info2 = get_field('author_knowabout_2', 'user_'. $author_id ); $author_info3 = get_field('author_knowabout_3', 'user_'. $author_id ); $author_info4 = get_field('author_knowabout_4', 'user_'. $author_id ); $author_info5 = get_field('author_knowabout_5', 'user_'. $author_id ); $author_info = $author_info1; if (isset($author_info2)) { $author_info = $author_info . ', ' . $author_info2; } if (isset($author_info3)) { $author_info = $author_info . ', ' . $author_info3; } if (isset($author_info4)) { $author_info = $author_info . ', ' . $author_info4; } if (isset($author_info5)) { $author_info = $author_info . ', ' . $author_info5; } return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'author_job', [ 'name' => esc_html__('Author Job', 'rank-math'), 'description' => esc_html__('Author Job Info', 'rank-math'), 'variable' => 'author_job', 'example' => author_job_callback(), ], 'author_job_callback' ); }); /* Each function returns the processed information, which is then used as an example value for the corresponding custom variable. */ function author_job_callback() { global $post; $author_id = $post->post_author; $author_info = get_field('author_jobtitle', 'user_'. $author_id ); return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'author_alumni', [ 'name' => esc_html__('Author Alumni', 'rank-math'), 'description' => esc_html__('Author Alumni Info', 'rank-math'), 'variable' => 'author_alumni', 'example' => author_alumni_callback(), ], 'author_alumni_callback' ); }); function author_alumni_callback() { global $post; $author_id = $post->post_author; $author_info = get_field('author_alumniof', 'user_'. $author_id ); return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'author_alumni_url', [ 'name' => esc_html__('Author Alumni URL', 'rank-math'), 'description' => esc_html__('Author Alumni URL Info', 'rank-math'), 'variable' => 'author_alumni_url', 'example' => author_alumni_url_callback(), ], 'author_alumni_url_callback' ); }); function author_alumni_url_callback() { global $post; $author_id = $post->post_author; $author_info = get_field('author_alumniof_url', 'user_'. $author_id ); return $author_info; } /*The code also includes a filter that affects the display of author templates. It returns false if the current page is an author archive, which might be used to prevent certain actions on author archive pages. */ add_filter( 'generate_do_template_part', function( $do ) { if ( is_author() ) { return false; } return $do; } ); add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_knowsabout', [ 'name' => esc_html__('reviewer Knowns About', 'rank-math'), 'description' => esc_html__('reviewer Knowns About Info', 'rank-math'), 'variable' => 'reviewer_knowsabout', 'example' => reviewer_knowabout_callback(), ], 'reviewer_knowabout_callback' ); }); function reviewer_knowabout_callback() { $author_id = get_field('reviewed_by'); $author_info1 = get_field('author_knowabout', 'user_'. $author_id ); $author_info2 = get_field('author_knowabout_2', 'user_'. $author_id ); $author_info3 = get_field('author_knowabout_3', 'user_'. $author_id ); $author_info4 = get_field('author_knowabout_4', 'user_'. $author_id ); $author_info5 = get_field('author_knowabout_5', 'user_'. $author_id ); $author_info = $author_info1; if (isset($author_info2)) { $author_info = $author_info . ', ' . $author_info2; } if (isset($author_info3)) { $author_info = $author_info . ', ' . $author_info3; } if (isset($author_inf42)) { $author_info = $author_info . ', ' . $author_info4; } if (isset($author_info5)) { $author_info = $author_info . ', ' . $author_info5; } return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_job', [ 'name' => esc_html__('reviewer Job', 'rank-math'), 'description' => esc_html__('reviewer Job Info', 'rank-math'), 'variable' => 'reviewer_job', 'example' => reviewer_job_callback(), ], 'reviewer_job_callback' ); }); function reviewer_job_callback() { $author_id = get_field('reviewed_by'); $author_info = get_field('author_jobtitle', 'user_'. $author_id ); return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_alumni', [ 'name' => esc_html__('reviewer Alumni', 'rank-math'), 'description' => esc_html__('reviewer Alumni Info', 'rank-math'), 'variable' => 'reviewer_alumni', 'example' => reviewer_alumni_callback(), ], 'reviewer_alumni_callback' ); }); function reviewer_alumni_callback() { $author_id = get_field('reviewed_by'); $author_info = get_field('author_alumniof', 'user_'. $author_id ); return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_alumni_url', [ 'name' => esc_html__('reviewer Alumni URL', 'rank-math'), 'description' => esc_html__('reviewer Alumni URL Info', 'rank-math'), 'variable' => 'reviewer_alumni_url', 'example' => reviewer_alumni_url_callback(), ], 'reviewer_alumni_url_callback' ); }); function reviewer_alumni_url_callback() { $author_id = get_field('reviewed_by'); $author_info = get_field('author_alumniof_url', 'user_'. $author_id ); return $author_info; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_name', [ 'name' => esc_html__('reviewer name', 'rank-math'), 'description' => esc_html__('reviewer nameInfo', 'rank-math'), 'variable' => 'reviewer_name', 'example' => reviewer_name_callback(), ], 'reviewer_name_callback' ); }); function reviewer_name_callback() { $author_id = get_field('reviewed_by'); $user_info = get_userdata($author_id); return $user_info->display_name; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_url', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_url', 'example' => reviewer_url_callback(), ], 'reviewer_url_callback' ); }); function reviewer_url_callback() { $author_id = get_field('reviewed_by'); return get_author_posts_url($author_id); } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_description', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_description', 'example' => reviewer_description_callback(), ], 'reviewer_description_callback' ); }); function reviewer_description_callback() { $author_id = get_field('reviewed_by'); return get_the_author_meta('user_description', $author_id); } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_sameAs', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_sameAs', 'example' => reviewer_sameAs_callback(), ], 'reviewer_sameAs_callback' ); }); function reviewer_sameAs_callback() { $author_id = get_field('reviewed_by'); $explode = explode(" ", get_the_author_meta('additional_profile_urls', $author_id)); return $explode[0]; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_sameAs2', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_sameAs2', 'example' => reviewer_sameAs2_callback(), ], 'reviewer_sameAs2_callback' ); }); function reviewer_sameAs2_callback() { $author_id = get_field('reviewed_by'); $explode = explode(" ", get_the_author_meta('additional_profile_urls', $author_id)); return $explode[1]; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_sameAs3', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_sameAs3', 'example' => reviewer_sameAs3_callback(), ], 'reviewer_sameAs3_callback' ); }); function reviewer_sameAs3_callback() { $author_id = get_field('reviewed_by'); $explode = explode(" ", get_the_author_meta('additional_profile_urls', $author_id)); return $explode[2]; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_sameAs4', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_sameA4s', 'example' => reviewer_sameAs4_callback(), ], 'reviewer_sameAs4_callback' ); }); function reviewer_sameAs4_callback() { $author_id = get_field('reviewed_by'); $explode = explode(" ", get_the_author_meta('additional_profile_urls', $author_id)); return $explode[3]; } add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'reviewer_sameAs5', [ 'name' => esc_html__('reviewer url', 'rank-math'), 'description' => esc_html__('reviewer url', 'rank-math'), 'variable' => 'reviewer_sameAs5', 'example' => reviewer_sameAs5_callback(), ], 'reviewer_sameAs5_callback' ); }); function reviewer_sameAs5_callback() { $author_id = get_field('reviewed_by'); $explode = explode(" ", get_the_author_meta('additional_profile_urls', $author_id)); return $explode[4]; } // kill all extra feed links in the head remove_action('wp_head','feed_links_extra', 3); // Rank Math Site Map Issue add_filter( 'rank_math/sitemap/enable_caching', '__return_false');Hello,
We recommend adding some if statements in the callback function that you are using to add custom variables to make sure that you are pulling in the data only when it’s available.
At the moment those errors happen when you are on a page that doesn’t have the global
$postvariable defined so those are expected.Don’t hesitate to get in touch if you have any other questions.
The If statements worked great, thank you
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.
The ticket ‘Rank Math Causing Error And CPU Overage’ is closed to new replies.