问题描述
如果我的措辞令人困惑,请见谅。我对 PHP 很陌生,但仍然不太了解它。
我正在编辑我的店面子主题的 content-single.PHP。 我制作了一些自定义字段,我希望它们位于我帖子的内容中。
但我只能设法将其置于内容之上或之下。
这是我的代码:
<?PHP
/**
* Template used to display post content on single pages.
*
* @package storefront
*/
?>
<article id="post-<?PHP the_ID(); ?>" <?PHP post_class(); ?>>
<?PHP
do_action( 'storefront_single_post_top' );
the_field('test');
/**
* Functions hooked into storefront_single_post add_action
*
* @hooked storefront_post_header - 10
* @hooked storefront_post_content - 30
*/
do_action( 'storefront_single_post' );
/**
* Functions hooked in to storefront_single_post_bottom action
*
* @hooked storefront_post_nav - 10
* @hooked storefront_display_comments - 20
*/
do_action( 'storefront_single_post_bottom' );
?>
</article><!-- #post-## -->
感谢您的帮助!
解决方法
在functions.php中试试这个
add_filter('storefront_post_content','add_acf',10,1);
function add_acf( $value ) {
$value = get_field('test');
return $value;
};
,我最终只使用 elementor 来解决这个特定问题