[网页]:如何解除主题限制新建独立页面

7次阅读
没有评论

Puock 主题默认提供了十几种不同的模板,但都会基于现有现状页眉、页脚、侧边栏设计,如何新建一个完全空白的页面呢?

 [网页]:如何解除主题限制新建独立页面

方法一:

Elementor 构建器,但是Elementor 会明显影响网站速度。加载 Elementor 的样式库和脚本库会产生速度损失(约 200-500KB)。

方法二:

  1. 用 FTP 或文件管理器,进入主题目录:/wp-content/themes/puock/
  2. 新建文件page-blank.php
  3. 粘贴以下代码完全空白,不加载任何主题样式和布局
  4. 保存后,在 WordPress 后台新建页面 → 右侧「模板」→ 选择 「纯净空白页」
<?php
/**
 * Template Name: 纯净空白页
 * Template Post Type: page
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
    <?php while (have_posts()) : the_post(); ?>
        <div style="padding: 20px;">
            <?php the_content(); ?>
        </div>
    <?php endwhile; ?>
    <?php wp_footer(); ?>
</body>
</html>

如果只禁用侧边栏和主题样式(保留基础结构)

<?php
/**
 * Template Name: 无侧边栏空白页
 * Template Post Type: page
 */

// 强制禁用侧边栏
add_filter('puock_sidebar_hide', '__return_true');

get_header(); ?>

<div id="content" class="container mt20">
    <div class="col-12">
        <?php while (have_posts()) : the_post(); ?>
            <article>
                <?php the_content(); ?>
            </article>
        <?php endwhile; ?>
    </div>
</div>

<?php get_footer(); ?>
正文完
 0
评论(没有评论)