首页 > 解决方案 > 如何在WordPress中的帖子标题上添加标题

问题描述

我想在所有帖子的标题之上添加一个附加到 URL 的标题。如何使用 CSS 或 Jquery 实现它?

具体可以参考下图。

https://i.imgur.com/qKPwrvZ.png

标签: wordpresswordpress-themingcustom-wordpress-pages

解决方案


这可以通过多种方式实现,

  1. 您可以安装插件 ACF 将帖子元字段添加到每个帖子

  2. 在您的主题文件中打开 index.php 或打开您获取所有帖子的模板文件。

    **

    确保将代码粘贴到文件中的适当位置,并确保将其粘贴在此行之后:

     <?php while ( have_posts() ) : the_post(); ?>
    
     And before:
    
     <?php endwhile; // end of the loop. ?>
    
     Use the following snipped to embed the metadata, changing the class name, field name and HTML formatting as required.
    
     <p class="myfieldname"><?php the_field('Field_Name'); ?></p>
    
     Save the file, and head to your site’s front-end to review.
    

**


推荐阅读