Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9241033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:17:42+00:00 2026-06-18T08:17:42+00:00

What action or filter can I use in a WordPress plugin to dynamically replace

  • 0

What action or filter can I use in a WordPress plugin to dynamically replace the contents (i.e. not the header or footer) of a 404 error page?

Basically I’m looking for a 404 error page equivalent for the_content filter, which will filter the contents of an existing page.

Thank you for your time.

Note: I know I can manually modify the 404 error page for the current theme, but that is not the effect I am trying to achieve.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:17:43+00:00Added an answer on June 18, 2026 at 8:17 am

    From this WordPress Answer: How to control output of custom post type without modifying theme?

    Plugin file:

    <?php
    /*
    Plugin Name: Plugin 404 Page
    Plugin URI: http://stackoverflow.com/questions/14539884
    Description: Use the plugin's template file to render a custom 404.php
    Author: brasofilo
    Author URI: https://wordpress.stackexchange.com/users/12615/brasofilo
    Version: 2013.26.01
    License: GPLv2
    */
    class Universal_Template
    {
        public function __construct()
        {       
            $this->url = plugins_url( '', __FILE__ );   
            $this->path = plugin_dir_path( __FILE__ );
            add_action( 'init', array( $this, 'init' ) );
       }
    
        public function init() 
        {
            add_filter( 'template_include', array( $this, 'template_404' ) );
        }
    
        public function template_404( $template ) 
        {
            if ( is_404() )
                $template = $this->path . '/404.php';
    
            return $template;
        }
    }
    
    $so_14539884 = new Universal_Template();
    

    And in the plugin folder, a file named 404.php:

    <?php
    /**
     * The template for displaying 404 pages (Not Found).
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
        <div id="primary" class="site-content">
            MY 404!
        </div><!-- #primary -->
    
    <?php get_footer(); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out what action hook/filter I can use to insert content
i would like to use custom post_type in my wordpress plugin but i have
I'd like to use an action filter to translate an Odata uri to a
How can I set up a default value in my Action Filter when an
I have an on my MVC View page. I use JQuery to filter a
The tutorial says to use android.appwidget.action.APPWIDGET_UPDATE in the action element within the XML intent-filter
I made a new action filter (attribute, similar to [Authorize]) which authorizes access to
I have a custom validation attribute derived from action filter attribute. Currently the attribute
In ASP.NET MVC 2, a couple of new action filter attributes were introduced, as
i filter the intent like this <intent-filter> <action android:name=android.nfc.action.NDEF_DISCOVERED/> <category android:name=android.intent.category.DEFAULT/> <data android:mimeType=text/plain />

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.