404 monitoring not triggered when get_header() function isn’t run

  • Hi! I love using RankMath! I just stumbled over an issue:

    404 errors are not being logged when the get_header() isn’t running in the theme. As a custom theme developer I use Timber as a templating engine. As we have a custom wrapper we do not have to run get_header to get the header.php template file. After I run into the issue that the errors weren’t being monitored I checked the RankMath code and found out that the 404 monitoring function only runs on the get_header action. Since I do not use this function within my Twig/Timber powered templates the monitoring function isn’t running.

    RankMath\Monitor\Monitor::capture_404 is the function that only runs on get_header() and is being hooked in RankMath\Monitor\Monitor::__construct it might be a better idea to run this function on the WP filter pre_handle_404() Let me know if I can help testing. 🙂

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    I’ve forwarded your suggestion to our Development team if it’s something that we’re able to introduce, we’ll be sure to let you know.

    For now, you can edit the hook in the plugin’s file. I don’t think pre_handle_404 is a right hook to log 404, you can change it to wp.

    I hope that helps. Thank you.

    • This reply was modified 1 month, 2 weeks ago by Pratik.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘404 monitoring not triggered when get_header() function isn’t run’ is closed to new replies.