【问题标题】:Insert a Wordpress contact form 7 in a custom template page在自定义模板页面中插入 Wordpress 联系表单 7
【发布时间】:2017-04-11 11:54:55
【问题描述】:

我一直在尝试在自定义“空白”页面模板中插入 WP 联系表单 7。

实际上我想要做的是将 WP CF7 功能插入一个非常基本、干净的页面(只是一个漂亮的背景,能够调整字体、图像......)但我不希望页面看起来像这篇来自 WP 主题的博文..

我尝试使用 FTP 上传白页模板, 但是当我尝试使用空白模板在新页面中嵌入 WPCF7 代码时,没有任何反应...

谁能帮帮我?

非常感谢!

白页模板

   <?php /* Template Name: Blank Page
*
* A blank custom page template.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
*/
?>


<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>

【问题讨论】:

  • 你可以在模板中echo do_shortcode()
  • 为什么在模板中使用echo do_shortcode()
  • @DhruvinMoradiya 阅读上文

标签: php html wordpress


【解决方案1】:

像这样编写你的代码:

<?php
/* Template Name: Blank Page
*
* A blank custom page template.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
*/

get_header();

$id= get_the_ID(); 
$post = get_post($id); 
$content = apply_filters('the_content', $post->post_content); 
echo $content; 

get_footer();

【讨论】:

    猜你喜欢
    • 2012-09-05
    • 2015-11-03
    • 2012-10-22
    • 2013-07-23
    • 2020-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    相关资源
    最近更新 更多