dongni3854 2016-12-23 21:44
浏览 49
已采纳

为什么我不能在我的Wordpress主题的PHP模板文件中编辑HTML

There is barely any HTML in the main page.php template file. It's very unspecific and I can't edit individual elements and alter my webpage accurately. I'm able to delete things like entire headers, but I've seen other themes that have PHP template files that include most of the page structure, which gave me fine control over the web page.

<?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' ); ?>">
  • 写回答

1条回答 默认 最新

  • dongshiru5913 2016-12-23 22:02
    关注

    The file you are working in Is for Displays all of the <head> section and everything up till <div id="content"> It is the other theme files you want to be editing. example templates/header/header-layout-one and so on you might want to play around with a simpler theme first But start off with making your theme into a child theme follow the instructions here https://codex.wordpress.org/Child_Themes as to not break site or lose changes on update and then you can start editing the theme to suite your needs.

    Be sure to read

    How do I ask a good question? https://stackoverflow.com/help/how-to-ask

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵