WordPress:如何制作单个帖子模板

问题描述 投票:0回答:1

我没有找到任何正确的答案,没有尝试在互联网上销售模板或 WordPress 添加。

我有一个 WordPress 网站,人们在写文章。我正在寻找解决方案:

  • 我需要所有帖子都具有相同的模板
  • 如果我更改帖子模板上的某些内容,我需要以前的帖子来更新其显示,以避免更新 x 旧帖子

到目前为止,我可以在发新帖子时复制模板,但如果我更改模板,它不会更新。

感谢您的帮助

wordpress wordpress-theming elementor custom-wordpress-pages
1个回答
0
投票

如果您不介意我问您是否使用自定义页面或 single.php - Single.php 会覆盖每个正常帖子并按原样显示它,这是您的问题吗? ,also // 显示你想要的内容 内容();应该显示从块或普通编辑器添加到该页面的任何更改。

https://developer.wordpress.org/themes/basics/organizing-theme-files/

<?php
get_header();

// Start the loop
if (have_posts()) :
    while (have_posts()) : the_post();
        // Get the author ID
        $author_id = get_the_author_meta('ID');
?>
        <article>
            <h2><?php the_title(); ?></h2>
            <p>Posted by <?php the_author(); ?></p>
            <div>
                <?php
                // Display the content you want 
                the_content();
                ?>
            </div>
        </article>
<?php
    endwhile;
else :
    echo 'No posts found';
endif;

get_footer();
?>
© www.soinside.com 2019 - 2024. All rights reserved.