[英]Wordpress: Editing date, author and other stuff from a post in a template
我正在使用“ 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的新手。
有什么建議么?
作者,發布的日期和時間是發布元項目,可以在post-meta.php
文件中找到。
在第111行附近查找函數generate_posted_on()
(但可能會有所不同,具體取決於版本,我只是下載了最新版本以查找它,但您的版本可能有所不同)
作為其他參考,可以在很多地方找到調用其父函數( generate_post_meta
)的代碼,但是根據您的要求,從content-single.php
開始。
/**
* The template for displaying single posts.
*
* @package GeneratePress
*/
一種簡單的方法
<?php get_template_part( 'content', 'single' ); ?>
此代碼正在加載content.php的模板部分。 因此,在主題文件夾中找到content.php,然后復制content.php中的所有代碼並替換上面的代碼段
這樣您就可以編輯作者,日期以及任何您想要的內容。
確保僅在新聞模板中將代碼段替換為content.php的整個代碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.