要为WordPress主题添加自定义的404页面,可以按照以下步骤进行操作:
404.php
,这将是您的自定义404页面的模板文件。404.php
文件,并根据您的设计和需求添加所需的HTML和CSS代码。以下是一个简单的示例404.php
文件的代码:
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<section class="error-404 not-found">
<header class="page-header">
<h1 class="page-title"><?php esc_html_e( 'Oops! That page can’t be found.', 'your-theme-text-domain' ); ?></h1>
</header>
<div class="page-content">
<p><?php esc_html_e( 'It looks like nothing was found at this location.', 'your-theme-text-domain' ); ?></p>
<p><?php esc_html_e( 'Please try searching or use the navigation menu to navigate to a different page.', 'your-theme-text-domain' ); ?></p>
</div>
</section>
</main>
</div>
<?php get_footer(); ?>
404.php
文件到您的主题文件夹中。