Ric*_*ard 1 html wordpress wordpress-theming
我正在为WordPress网站创建一个页面模板.
在newpagetemplate.php文件中,我目前有这段代码,而且这段代码只有:
<html>
<body>
<?php
/*
Template Name: Salespage
*/
?>
<div>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我需要修改,设置边距,字体等值.
在上面的代码中,我需要'html'和'body'标签吗?
(如果我取出这些标签,应用此页面模板的页面仍然显示正常.)
我不知道你为什么收到这么多理论答案.那对我来说似乎是一种无趣的浪费时间.
简单的答案是否定的.
从您提供的代码,看起来好像您正在尝试构建自定义Wordpress主题.您需要放置doctype并打开html/body标签header.php
,然后关闭这些标签footer.php
.然后,从"Salespage"模板中提取页眉和页脚模板.它可能看起来像这样:
// header.php
<!DOCTYPE html>
<html>
<head>
<title>Your Title</title>
<?php wp_head(); ?>
</head>
<body>
Run Code Online (Sandbox Code Playgroud)
// newpagetemplate.php
<?php get_header(); ?>
<div class="yourContent">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Run Code Online (Sandbox Code Playgroud)
// footer.php
<?php wp_footer(); ?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1411 次 |
最近记录: |