我使用的是Generate Press模板,我想要自定义帖子页面。我修改了single.php,这样我就可以改变CSS和PHP。不过,我希望能够更改作者姓名、日期和内容的出现顺序。
<main id="mein" <?php generate_main_class(); ?>>
<?php do_action('generate_before_main_content'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo">Simple collapsible</button>
<div id="demo" class="collapse">
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) : ?>
<div class="comments-area">
<?php comments_template(); ?>
</div>
<?php endif; ?>
</div>
<?php endwhile; // end of the loop. ?>
<?php do_action('generate_after_main_content'); ?>
</main><!-- #main -->
我在代码中找不到任何地方来改变这一点。我只能将其作为一个组进行修改。另外,我还是个PHP新手。
有什么建议吗?
发布于 2018-06-12 06:20:07
发布的作者、日期和时间是发布的元项,可以在post-meta.php
文件中找到。
查找第111行附近的函数generate_posted_on()
(但可能会有所不同,具体取决于版本,我刚刚下载了最新版本来查找它,但您的可能会有所不同)
为了获得更多参考,可以在许多地方找到调用其父函数(generate_post_meta
)的代码,但是为了满足您的需求,请从content-single.php
开始。
/**
* The template for displaying single posts.
*
* @package GeneratePress
*/
发布于 2018-06-12 17:28:11
一个简单的方法,
<?php get_template_part( 'content', 'single' ); ?>
这段代码正在加载content.php的模板部分。因此,在您的主题文件夹中找到content.php,复制content.php中的所有代码并替换上面的代码片段
这样你就可以编辑作者,日期和任何你想要的东西。
确保在您的新闻模板中仅用content.php的完整代码替换代码片段
https://stackoverflow.com/questions/50805845
复制相似问题