Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何只在word press上的博客文章中添加标题和日期_Php_Wordpress - Fatal编程技术网

Php 如何只在word press上的博客文章中添加标题和日期

Php 如何只在word press上的博客文章中添加标题和日期,php,wordpress,Php,Wordpress,我是WordPress的新手,我试图只在博客帖子上显示标题和发布日期。我在谷歌搜索和狂饮时找不到任何答案。当前,无论页面显示的是页面标题还是制作日期 以下是我正在使用的索引代码: <?php get_header(); ?> <div id="main"><br><br> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post

我是WordPress的新手,我试图只在博客帖子上显示标题和发布日期。我在谷歌搜索和狂饮时找不到任何答案。当前,无论页面显示的是页面标题还是制作日期

以下是我正在使用的索引代码:

    <?php get_header(); ?>
<div id="main"><br><br>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>

<p><?php the_content(__('(more...)')); ?></p>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<br> <?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<div id="delimiter">
</div>
<?php get_footer(); ?>



张贴在

我知道这是在呼唤每一页的标题和短语“张贴在”。我想知道如何让它的地方,它将只显示在我的博客文章


提前感谢。

更好的方法是编辑与相应页面相关的内容

在当前代码中,可以检查循环中当前帖子的帖子类型。然后有条件地显示标题和日期

<?php get_header(); ?>
<div id="main"><br><br>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php $postType = get_post_type();

if($postType == 'post'){ ?>
<h1><?php the_title(); ?></h1>
<?php } ?>

<p><?php the_content(__('(more...)')); ?></p>

<?php if($postType == 'post'){ ?>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<?php } ?>

<br> <?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<div id="delimiter">
</div>
<?php get_footer(); ?>



张贴在


如何为博客页面使用模板?我在博客页面上看不到模板选项。你是指单个博客页面(实际发布)还是博客存档页面?