【问题标题】:Why can't I edit HTML in my Wordpress theme's PHP template files为什么我不能在我的 Wordpress 主题的 PHP 模板文件中编辑 HTML
【发布时间】:2016-12-23 21:44:03
【问题描述】:

主 page.php 模板文件中几乎没有任何 HTML。它非常不具体,我无法编辑单个元素并准确更改我的网页。我可以删除整个标题之类的内容,但我看到其他主题的 PHP 模板文件包含大部分页面结构,这让我可以很好地控制网页。

<?php
/**
 * The header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="content">
 *
 * @package Nikkon
 */
global $woocommerce;
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<div id="page" class="hfeed site <?php echo sanitize_html_class( get_theme_mod( 'nikkon-slider-type' ) ); ?>">

<?php echo ( get_theme_mod( 'nikkon-site-layout' ) == 'nikkon-site-boxed' ) ? '<div class="site-boxed">' : ''; ?>

    <?php if ( get_theme_mod( 'nikkon-header-layout' ) == 'nikkon-header-layout-three' ) : ?>

        <?php get_template_part( '/templates/header/header-layout-three' ); ?>

    <?php else : ?>

        <?php get_template_part( '/templates/header/header-layout-one' ); ?>

    <?php endif; ?>

    <?php if ( is_front_page() ) : ?>

        <?php get_template_part( '/templates/slider/homepage-slider' ); ?>

    <?php endif; ?>

    <div class="site-container <?php echo ( ! is_active_sidebar( 'sidebar-1' ) ) ? sanitize_html_class( 'content-no-sidebar' ) : sanitize_html_class( 'content-has-sidebar' ); ?>">

【问题讨论】:

    标签: php html wordpress templates


    【解决方案1】:

    您正在处理的文件是Displays all of the &lt;head&gt; section and everything up till &lt;div id="content"&gt; 这是您要编辑的其他主题文件。例如templates/header/header-layout-one 等等,你可能想先玩一个更简单的主题但是首先将你的主题变成一个子主题,按照这里的说明https://codex.wordpress.org/Child_Themes,以免破坏网站或在更新时丢失更改,然后你可以开始编辑主题以满足您的需求。

    请务必阅读

    如何提出一个好问题? https://stackoverflow.com/help/how-to-ask

    【讨论】:

    • 您应该将此添加为评论,因为它不是答案。对于 OP 看看 childthemes,这就是你想要使用的。您不想编辑原始主题文件。您将丢失更新时所做的更改。
    • 你是对的@RST 我总是将主题作为子主题工作,但问题太模糊了,我只想指出他找错地方了。我会更新的。
    猜你喜欢
    • 2016-08-05
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    • 2023-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多