首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在主题文件编辑器中放置帖子标题

如何在主题文件编辑器中放置帖子标题
EN

Stack Overflow用户
提问于 2022-10-05 01:03:20
回答 1查看 67关注 0票数 1

大家好,我只想问一问,是否可以在名称中添加帖子标题:在个人信息下,我想将user_name更改为post标题,以及如何将帖子标题添加到自定义元字段中

代码语言:javascript
复制
<?php
/**
 * The template for displaying all single posts.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package Astra
 * @since 1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

get_header(); ?>

<?php if ( astra_page_layout() == 'left-sidebar' ) : ?>

    <?php get_sidebar(); ?>

<?php endif ?>

    <div id="primary" <?php astra_primary_class(); ?>>

        <?php astra_primary_content_top(); ?>
        
        <div class="custom-metafields">
    <ul>
        <h4>
            <strong>I. Personal Information</strong>
        </h4>
        <li><strong>Name: </strong> <?php the_field('user_name'); ?></li>
        <li><strong>Date of Birth: </strong> <?php the_field('Date_Birth'); ?></li>
        <li><strong>Age: </strong> <?php the_field('user_age'); ?></li>
        <li><strong>Occupation: </strong> <?php the_field('user_occupation'); ?></li>
        <li><strong>Marital Status: </strong> <?php the_field('marital_status'); ?></li>
        <br>
        <br>
        <h4>
            <strong>II. Contact Information</strong>
        </h4>
        <li><strong>Email Address: </strong> <?php the_field('email_address'); ?></li>
        <li><strong>Phone Number: </strong> <?php the_field('phone_number'); ?></li>
        <li><strong>Address: </strong> <?php the_field('user_address'); ?></li>
        <br>
        <br>
        <h4>
            <strong>III. Report Details</strong>
        </h4>
            <li><strong>Type of Abuse: </strong> <?php the_field('Type_Abuse'); ?></li>
            <li><strong>Photo Evidence: </strong></li>
    </ul>
    </div>
        <?php astra_content_loop(); ?>

        <?php astra_primary_content_bottom(); ?>

    </div><!-- #primary -->

<?php if ( astra_page_layout() == 'right-sidebar' ) : ?>

    <?php get_sidebar(); ?>

<?php endif ?>

<?php get_footer(); ?>
EN

回答 1

Stack Overflow用户

发布于 2022-10-05 08:28:52

你可以这样做:

代码语言:javascript
复制
<li><strong>Name: </strong> <?php the_title(); ?></li>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73955012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档