Lir*_*epi 4 php wordpress visual-studio-code
我正在尝试显示 ACF 的数据,但在 Visual Studio Code 中收到此错误:
这是整个代码。我尝试重新安装插件,将 PHP 添加到路径中,但似乎没有任何效果。
Single.php
<?php get_header();?>
<div class="container">
<div class="row">
<div>
<img src="<?php the_post_thumbnail_url('thumbnail'); ?>" id="single_header">
<div id="single_content">
<?php if (have_posts()):while (have_posts()):the_post(); ?>
<?php
$fn=get_the_author_meta('first_name');
$lname=get_the_author_meta('last_name');
$email=get_the_author_meta('email');
?>
<h1 class="text=cenetr nt-3 mb-5 text-primary"><?php the_title();?></h1>
<small>Publishor:<?php echo $fn; ?></small>
<p><?php the_content();?></p>
<?php
endwhile;
endif;
?>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div>
<div id="single_extraInfo">
<p>Company: <?php the_field('flight_company'); ?></p>
<p>Date: <?php the_field('flight_date'); ?></p>
<p>Capacity: <?php the_field('flight_capacity'); ?></p>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Run Code Online (Sandbox Code Playgroud)
小智 7
除了上面@DaleNguyen 的建议之外......
确保包含acf 插件的目录位于您的Vs Code中。例如,不要只打开您可能正在使用的 VS Code 中的主题目录,而是在 VS Code 中打开整个wp_content目录。这样,当 intelephence 在后台运行时,它将能够访问插件文件夹和acf 插件文件夹中的acf 函数。
在 中intelephense,确保您添加wordpress到列表中。