18910140161

简化函数将HTML混合到PHP

顺晟科技

2021-09-09 12:38:46

230

我一直在学习更好的做事方法,我想看看是否可以从社区获得一个输入,看看是否有一种方法可以改进这个功能:

function pardot_dashboard_query() { $args = [ 's' => '<!-- wp:acf/pardot-form ', 'sentence' => 1, 'post_type' => [ 'post', 'page' ], ]; $pardot_posts = get_posts($args); if (!$pardot_posts) { echo 'There are no active Pardot Forms.'; return; } echo '<p>The Pardot Form is active on the following pages/posts:</p>'; ?> <ul> <?php foreach ($pardot_posts as $post): ?> <li><a href="<?= $post->guid ?>"><?= $post->post_title ?: 'No title available' ?><?= ' (' . ucfirst($post->post_type) . ')' ?></a></li> <?php endforeach; ?> </ul> <?php }

如果有其他输出方式或缩小输出的方法-将不胜感激!


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航