我最近从http://wpeventsplus.com/购买了事件+ Wordpress插件,我试图让日历显示在模板页面上。但是,短代码[PLUS_CALENDAR]在我编写的模板页面上不起作用。下面是这个页面的全部代码:
<?php
/*
Template Name: page-registration
*/
?>
<?php get_header(); ?>
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
<?php get_footer(); ?>
我的背景是HTML和CSS,我对php不太熟悉。我还应该提到的是,我的网站是从一个正常的HTML网站转换而来的WP主题,这使得使用插件有点困难,因为代码并没有以一种非常干净的方式转换为php。我猜我有一个错误,或几个,在我的代码,但我不知道从哪里开始寻找,我很感激任何帮助。谢谢。
你可以这样在WordPress PHP文件中执行短代码:
<?php echo do_shortcode('[PLUS_CALENDAR]'); ?>
详细信息:https://developer.wordpress.org/reference/functions/do_shortcode/
所以你的代码变成了:
<?php
/*
Template Name: page-registration
*/
?>
<?php get_header(); ?>
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
echo do_shortcode('[PLUS_CALENDAR]');
//
} // end while
} // end if
?>
<?php get_footer(); ?>