Articles of widgets

Showing a Thickbox (tb_show) does nothing

I’m trying to add a media uploader to a widget/plugin and I’m at the stage where I need to add a picture from the media library (or upload a new one). I added some javascript and added an event to a button in the plugin. This event gets fired (because the alert is displayed), but […]

passing variables inside a widget add_action

Here’s my code inside a widget class: function widget($args, $instance) { add_action(‘wp_footer’, function () { echo $instance[‘title’] }); } It doesn’t output $instance[‘title’]. I tried passing the $instance parameter in the function, and even tried global $instance;, but neither worked.

How to allow editing of text in sidebar?

I am developing a theme which has an area of the sidebar which displays the blog owner’s bio and photo as a background image. I could hard-code this information, however, I’d like to learn how to make this text (and possibly the background image) editable in the WordPress admin. I think this is referred to […]

Shortcode not working in widget

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 […]

Add footer widgets

My website is running on WordPress theme which does not have options to add footer widgets. How can I add it using other ways?

I've set up an extra field for all the available widgets. How do I show it's value in the front-end?

Thanks to another great post here I managed to set up an extra field (called “subtitle”) for all WP Widgets. Now I am trying to make all WP widgets display the value of this extra field (naturally, after_title, since it’s the subtitle), but I can’t quite figure this out. Here is the code I use […]

WordPress Widget Not Saving Instance

I have very simple wordpress widget, that has 3 input field. Whenever i submit data, it does not save to database. I have added and deleted the plugin , deactivated and reactivated multiple times, but no luck. Below is my code :- class price_package extends WP_Widget { function __construct() { parent::__construct( ‘price_package’, ‘Price Package’, array( […]

How to use title attributes in sidebar widget?

I have a custom post type “article” & I need to display some custom urls is a widget in the sidebar using php code widget. When I use this code withing the loop it works perfectly: <a href=”<?php echo site_url(‘/article/full-text/’); ?> <?php $slug = $post->post_name; echo $slug; ?>” title=”<?php the_title_attribute(); ?>”>Full Text</a> but when I […]

Is it possible to remove <ul><li> from default category widget?

I´m having some difficulty override to default category widgets in my wordpress theme. I created the theme from scratch. I want to remove the <ul><li></li></ul> from categories in the lists. I want to add my own style using <a href=””></a> instead <div class=”list-group”> <a href=”#” class=”list-group-item”>LifeStyle</a> <a href=”#” class=”list-group-item”>SmartPhones</a> <a href=”#” class=”list-group-item”>Business</a> <a href=”#” class=”list-group-item”>Graphic […]

A/B test options at the widget level

I am looking for a method to show 1 of 3 different widgets on my site’s homepage. I could do this with javascript, but this would increase page weight and I would rather do it at time of render (native wp or php solution). The solution does not have to be a true A/B test […]