You have a conditional in your function that will skip (return) if the current “view” is not a single post. You also have an undefined variable $content
– the following has the condition removed and undefined variable fixed (always, always have debugging on when building with WordPress):
function newsletter_signup_shortcode( $atts ) {
$post_type = get_post_type(); // Not sure if you still need this for your MailChimp template?
// Attributes
extract( shortcode_atts(
array(
'location' => get_permalink(),
'show_title' => 'yes',
), $atts )
);
ob_start();
?>
<!-- MailChimp Signup Form outputs here - code omitted for clarity -->
<?php
return ob_get_clean();
}
Related Posts:
- Shortcode from a widget is wrapped in unwanted element
- How can I whitelist only specific shortcodes for processing in text widgets?
- When to use which plugin output method?
- Custom shortcode in widget forced to top of widget
- Shortcode in Text Widget not working
- Inserting shortcode [stream /] into a Text widget
- check for shortcode in post/pages AND widgets AND template files
- the_widget() and widget’s ID
- How the widget can be run by shortcode
- How do i display the built-in gallery inside a widget?
- Shortcode displays always first. Once again
- Create a widget to use shortcode?
- Check if the current shortcode is being used in a widget
- Display custom widget, added as a shortcode in the correct place
- Allow shortcode for custom widget
- call widget from within shortcode
- Transform php shortcode into a widget [duplicate]
- Can I use widgets & shortcode if I need to return an array?
- page url in shortcode
- How do I get shortcode, widget and template tag CSS to load in the head only as required? [duplicate]
- Can a widget in the Customizer be “single-use” (i.e. disabled after 1 instance has been added)?
- Does the number of widgets installed affect website performance?
- How to add color picker to widgets?
- Remove All Widgets from Sidebar
- How do I use the control callback when creating a simple dashboard plugin
- Unregistering a Sidebar in Child Theme
- is_active_sidebar() Always Returns False
- Different rss feeds in a single dashboard widget
- How could a Widget behave differently depending on sidebar
- Count widgets in position and set class
- iris color picker in widget – click event doesn’t fire when initially when widget is first created
- How do I add Widgets to my theme and activate them on my site?
- How to insert widget areas specific to certain pages (or posts, etc.)?
- Find if widget block is active
- Add Descriptive text to Widget text box so users can see what they contain
- PHP contact form returns warning in text widget [closed]
- Multiple users editting widgets
- How to rename wordpress Widget
- Trying to wrap around first word of multiple word strings with a widget_title() filter, only works on two word strings and not more than two
- Read file contents the WP way
- Create a widget that allows text input
- Subscribe2 widget with choosing categories?
- Showing a Thickbox (tb_show) does nothing
- jQuery UI inside widget on admin page
- How to activate or install the Gallery Widget?
- Custom User Field in Dashboard Widget
- Getting a div wrapped around two widgets
- How can I get the first section of a page 100% width, while the rest will have a sidebar? [closed]
- Widgets not adding div on before and after title
- Modify ‘Sizes’ Attribute for Images with Specific Class
- Issue understanding and using WordPress filters and actions
- How can I inject html after the [x]th widget inside a Sidebar? [duplicate]
- RSS dashboard widget not showing visuals
- Simple widget causing whitescreen
- How to stop comments widget conflicting with theme comments
- Grabbing how Many Posts by Month for a Dashboard Widget
- How to change the default class for the widget title?
- How to use wordpress content class?
- How to use get_results() in widget front end?
- How to best include widget area just on homepage?
- Proper approach to moving complete site from one domain to another AND preserve widgets
- Different widgets in sidebar on sub-children pages?
- Why custom widget won’t appear in Block editor (Gutenberg)?
- A/B test options at the widget level [closed]
- Random sidebar/widget background
- Any available action to add content before and after sidebar?
- Creating a widget that displays the content of a page
- How to place my g+ or fb plugin at the bottom of post or page?
- WordPress widget value not save?
- Countdown Widget
- recent comments filter by author, page, category
- Display Most Recent Post Widget Title On Page
- How do I get my custom widget to show on live site?
- How can I add a widget area to the top of the Dashboard?
- How do I enable the admin form for a custom widget that is called in a sidebar template, not to widget area?
- Accessing WooCommerce product categories before initialising widget areas
- Create a new recent post widget
- How to prevent Widget from echoing to wrong position in DOM
- Search box displaying just title → Default WordPress Widget for Search Box
- Need two sidebar (right and left)in Twenty Seven theme
- Fatal Error (Call to a member function… ) on production site, but not development site
- How to get number of posts in same category as current post?
- conditional widget title
- Create a setting at backend,to print only selected categries at front-end
- Widget Admin page and Javascript enqueuing
- Change Widget that display posts from categories to tags
- Registered widget is showing up collapsed in the dashboard
- Using AJAX in WordPress Widget
- Create a widget to display image and Title?
- How can I get the sidebar id on the current page?
- How add short description Featured Products or Related Products
- call coupon press advanced search widget anywhere in theme?
- Tabbed navigation in widget backend
- How to remove calendar widget?
- twenty twelve theme widgets not working
- How to completely remove the sidebar? [closed]
- Change the datasource of widget in a WordPress theme
- Random disappearance of footer widgets [closed]
- Can’t edit the widgets sidebar or footer
- Custom dashboard widget – load style only for added widget