یک فایل داخل روت پوشه قالب (جایی که فایل style.css هست) به نام دقیقا acf-custom.php بسازید و کدهای زیر رو داخلش قرار بدید:
<div class="book-meta">
<ul>
<li><strong>Author:</strong> <?php the_field('author'); ?></li>
<li><strong>Release Year:</strong> <?php the_field('release_year'); ?></li>
<li><strong>Book Rating:</strong> <?php the_field('book_rating'); ?>/10</li>
</ul>
بعد کل کدهای زیر رو کپی کنید و جایگزین کدهای فعلی فایل content کنید:
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
/**
* Template part for displaying content
*/
if ( is_singular() ) {
?>
<section class="l-section"><div class="l-section-h i-cf">
<?php
the_title( '<h1 class="entry-title">', '</h1>' );
} else {
?>
<article <?php post_class(); ?>>
<?php
the_title( sprintf( '<h2 class="entry-title"><a href="https://1go.ir/%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
}
// Display the content
the_content();
get_template_part( 'acf', 'custom' );
// Display post pagination
us_wp_link_pages( 1 );
// Display date
echo sprintf(
'<time class="entry-date published updated" datetime="%1$s">%2$s</time>',
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() )
);
// Display tags list, needed for Theme Check
the_tags();
// For posts loop
if ( is_singular() ) {
?>
</div></section>
<?php
} else {
?>
</article>
<?php
}
// Display the comments section
comments_template();
خواستم کدهای ACF رو مستقیما توی فایل قرار بدم دیدم یه سری تغییرات توی ساختار توابع و کدهای این فایل باید داده بشه که راحت ترین و بهترین روش رو که ساختن یک فایل جدید هست براتون انجام دادم.
بعد از اون تغییرات رو فقط از طریق فایل acf-custom.php اعمال کنید.