Site icon Hip-Hop Website Design and Development

Methods to redirect to class web page if web page doesn’t exists?

In my present case, the system attempt to discover a web page and present 404 if it doesn’t discover.
I would really like with the identical url… like https://instance.com/{{slug}}/

  1. Test if a web page with this slug exists :
      • Sure – present the web page
      • No – change to the class web page (with similar slug)
      • No class web page -> present web page 404

What’s the greatest recommandanted method to do that in WP?