我创建了以下短代码:
function newsletter_signup_shortcode( $atts ) {
$post_type = get_post_type();
// Attributes
extract( shortcode_atts(
array(
\'location\' => get_permalink(),
\'show_title\' => \'yes\',
), $atts )
);
// Return the unfiltered content if we\'re not on a post.
if ( $post_type != \'post\' ) {
return $content;
}
ob_start();
?>
<!-- MailChimp Signup Form outputs here - code omitted for clarity -->
<?php
// Add the opt-in form after the post content.
return $content . ob_get_clean();
}
add_shortcode( \'newsletter_signup\', \'newsletter_signup_shortcode\' );
这在主页和博客帖子页面、帖子和边栏小部件中都非常有效。但是,当我查看页面时,侧栏小部件不会显示短代码内容:
我错过了什么?