1 回答
TA贡献1828条经验 获得超6个赞
以下是如何稍微重构代码,以更易读的方式回显变量:
<?php while ( have_posts() ) : the_post();
if(Woocommerce_Pay_Per_Post_Helper::is_protected()){
//Page is protected
if(Woocommerce_Pay_Per_Post_Helper::has_access()){
// Do what you want to do if they have access to the page ?>
<div class="container">
<div class="row">
<div class="col-12">
<iframe width="560" height="315" src="<?php echo the_field("video_link"); ?>" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
<?php } else {
// the page is protected and the user does NOT have access
echo Woocommerce_Pay_Per_Post_Helper::get_no_access_content(); ?>
<div class="container">
<div class="row">
<div class="col-12">
<img src="<?php echo the_field("video_screenshot") ?>" />
</div>
</div>
</div>
<?php }
} else {
//Page is not protected do what you need to do.
}
endwhile; // end of the loop. ?>
- 1 回答
- 0 关注
- 71 浏览
添加回答
举报