Hi,
I’ve created an Error Page template in Bricks builder .
My permalink is setup as “%root_url%/blog/%postname%”
where
- “%root_url%” is our domain name
- “/blog” is a static in the URL so I’d have search/categories/posts be directed to “…/blog/<category/search/post>” URL when using archive/search/post template setup.
But this creates a problem when setting up the Error Page Template .
It works great when I use url “… /blog/<random_slug_in_url>”
BUT when navigating directly to “www.myrndmdomain33.com/<random_slug_in_url>” eg.
“http://www.myrndmdomain33.com/gibberishslug404throw”, it renders the default Bricks " Whoops, that page is gone" template.
I looked into other topics on this forum, it was suggested to create a filter for active templates, for example,
function itchy_disable_uncategorized_category_archives( $active_templates, $post_id, $content_type) {
if ( is_single() && is_category( ‘uncategorized’ ) ) {
global $wp_query;
$wp_query->set_404();
status_header( 404 );// Set the active templates to 404 template $active_templates['content'] = 196850; //Set error template ID $active_templates['error'] = 196850; // Set error template ID $active_templates['content_type'] = 'error';
}
return $active_templates;
}
But this does not catch it.
I assume it doesn’t fall under categorization. I’d need to set up the right conditions, then it would work, but I have no clue what the checks should be there . I tried it without any checks and it renders the Error Page Template.
How do I set up the routing for anything before “/blog” permalink to render the custom 404 Error Template I created ? example “www.myrandomdomain.com/gibberishslug404throw” ? (without the static “/blog” in URL)
TLDR;
- Permalink has following setup “/blog/%postname%” .
- Custom Error Template for the following URLs:
- “www.myrandomdomain.com/gibberishslug404throw” (doesn’t work, displays default Bricks template “Whoops…”)
- “www.myrandomdomain.com/blog/gibberishslug404throw” (this one works)
- How to display Custom Error Template for the first URL also ? Without breaking the /blog permalink setup.