Notifications
Clear all

How to add a redirect to a custom 404 page

5 Posts
2 Users
1 Likes
197 Views
Posts: 11
Topic starter
(@systemcrack)
Active Member
Joined: 1 year ago

Hi all, I wanted to know if there is a way to add a redirect to wpforo's default 404 page to a custom 404 page.

 

wpForo Version
2.1.7
WordPress Version
6.2.2
4 Replies
Posts: 3653
Admin
(@chris)
Support Team
Joined: 2 years ago

Hi @systemcrack,

You can use this hook for that:

$this->current_object = apply_filters( 'wpforo_after_init_current_object', $this->current_object, $wpf_url_parse );
Reply
3 Replies
(@systemcrack)
Joined: 1 year ago

Active Member
Posts: 11

Be patient @chris  where should i put this piece of code? By chance in the file:

.../wp-content/plugins/wpforo/themes/2022/404.php
Reply
Admin
(@chris)
Joined: 2 years ago

Support Team
Posts: 3653

@systemcrack,

I have provided the hook, but you still need to write a code which would redirect wpForo 404 page to your custom one.

If you cannot write the code, you can contact with Gvectors Custom work team with your request.

Contact Email: sales[at]gvectors.com

Reply
Admin
(@chris)
Joined: 2 years ago

Support Team
Posts: 3653
Inserting the code in Themes functions.php file
 
Add the code at the end(bottom) of the current active theme functions.php file
 
Option one: open functions.php file from wp-content > themes > current active theme.
 
Option Two: Go to Dashboard > Appearance Theme File Editor, select Theme Functions(functions.php) file from Theme Files Bar.
 
Please mention that the code can be lost after updating or changing the theme.
 
 
 
Solution by using Code Snippets Plugin
 
Install and Activate Code Snippets plugin( https://wordpress.org/plugins/code-snippets/).
 
Go to Dashboard > Snippets > Add New.
 
Insert the below code in code field:
 
Select Run snippet everywhere Radio and save the snippet.
 
Check that the new created snippet is active from Dashboard > Snippets > All Snippets.
Reply