我是wordpress的新手。
所以,我创建短代码来获取functions.php中的数据并在post中使用它。
function create_shortcode_test {
.....
return my_data;
}
add_shortcode ( 'test_shortcode' , 'create_shortcode_test' );
[test_shortcode]
我使用摘录进行发布。
example
在主页上,我可以看到摘录。
打开帖子后,我可以看到数据得到短代码。
但我想知道:
在主页上显示摘录和短代码工作
或发布仅显示摘录,短代码无效。并且在开放后短信码工作之后。
这意味着我想知道,如果我选择显示节选,在主页(只看摘录),短信在帖子(不是摘录)工作或不工作()在主页?
答案 0 :(得分:0)
您可以使用此简单方法显示the_excerpt,因为此标记位于循环中。
function create_shortcode_test {
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php endif; ?>
}
add_shortcode ( 'test_shortcode' , 'create_shortcode_test' );