I created the following shortcode:
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' );
This works great on the home page and blog post pages, within the post and in the sidebar widget.
However, when I view a page, the sidebar widget does not display the shortcode content:
What am I missing here?