Wordpress post 未显示
Wordpress post not displaying
header.php - 文件
我是 Wordpress 脚本的新手,不知道我做错了什么?我的 post 没有显示
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
在 header.php 中你应该添加这样的东西。
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
在你的前面-page.php或home.php或index.php**包含header.php和wordpress特定功能get_header()
然后呈现你的菜单,帖子像这样:
<?php
get_header();
if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
请参考this
** 如果您对使用哪个 php 文件感到困惑,请学习 WordPress hierarchy
您可以在 page.php 或 post.php 上编写代码,否则您可以创建模板并将代码放在下面并将页面分配给该模板。
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
Header.php
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header>
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
</header><!-- #masthead -->
<div id="content" class="site-content">
Output:
header.php - 文件
我是 Wordpress 脚本的新手,不知道我做错了什么?我的 post 没有显示
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
在 header.php 中你应该添加这样的东西。
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
在你的前面-page.php或home.php或index.php**包含header.php和wordpress特定功能get_header()
然后呈现你的菜单,帖子像这样:
<?php
get_header();
if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
请参考this
** 如果您对使用哪个 php 文件感到困惑,请学习 WordPress hierarchy
您可以在 page.php 或 post.php 上编写代码,否则您可以创建模板并将代码放在下面并将页面分配给该模板。
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
Header.php
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header>
<nav class="subnav">
<?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<div id="overview" class="tab">
<p><?php the_content(); ?></p>
</div>
</article>
<?php endwhile;?>
<?php endif; ?>
</header><!-- #masthead -->
<div id="content" class="site-content">
Output: