Skip to content

Codepolice

  • ⤫

Creating an empty/blank text widget for WordPress without additional markup and divs

Posted by Judy Alvarez Posted on February 28, 2022March 1, 2022
0

WordPress provides a simple text widget that you can use on your blog to add some random HTML, Ads, images, and so on. But I have one problem and that is that it’s always adding some extra HTML like this.

<div class="widget">
 <div class="textwidget">
 </div>
</div>

Sometimes you do not want this code if you for example want to add a widget to a ul and want the outer tag to be a li. I tried to Google for this but surprisingly I didn’t find a single “Super Empty Text Widget” so I created one myself.

/**
 * SuperEmptyWidget Class
 */
class SuperEmptyWidget extends WP_Widget {
    /** constructor */
    function SuperEmptyWidget() {
        parent::WP_Widget(false, $name = 'SuperEmptyWidget');
    }

    /** @see WP_Widget::widget */
    function widget($args, $instance) {
        extract( $args );
        $content = $instance['content'];
        echo $content;
    }

    /** @see WP_Widget::update */
    function update($new_instance, $old_instance) {
	$instance = $old_instance;
	$instance['content'] = $new_instance['content'];
        return $instance;
    }

    /** @see WP_Widget::form */
    function form($instance) {
        $content = esc_attr($instance['content']);
        ?>
         <p>
          <label for="<?php echo $this->get_field_id('content'); ?>"><?php _e('Content:'); ?></label>
		          </p>
          <textarea class="widefat" cols="20" rows="16" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"><?php echo $content; ?></textarea>

        <?php
    }

} // class SuperEmptyWidget

// register SuperEmptyWidget widget
add_action('widgets_init', create_function('', 'return register_widget("SuperEmptyWidget");'));

Just add that to your functions.php and you should have a widget that does not add any crap either before or after the content.

Categories: UncategorizedTagged: best free wordpress themes, cpanel wordpress, descargar wordpress, free wordpress templates, how to install wordpress, how to use wordpress, htaccess wordpress, localhost/wordpress/wp-login.php, plugins wordpress, themes wordpress, wordpress backup, wordpress dashboard, wordpress divi, wordpress docker, wordpress free, wordpress free themes, wordpress gratis, wordpress gutenberg, wordpress install, wordpress rest api, wordpress support, wordpress templates free, wordpress woocommerce, wordpress テーマ

Post navigation

Previous Previous post: IE9 mess up the color theme in Visual Studio when started
Next Next post: Entity Framework Scaffolding: The type is not mapped issue

Related Posts

  • Debug and fix the z-index bug in IE6 and IE7

    Internet Explorer 6 and 7 has a really really annoying bug that makes it really hard to use z-index. I won’t go into any specifics about exactly what is causing this and so on because others have already done that. I just want to tell you that I found this awesome jQuery script that injects z-index that

    Posted by Judy Alvarez Posted on February 28, 2022March 3, 2022
    0
  • Signing a request to set up a custom Amazon CloudFront Distribution with C#

    I love most of Amazon’s Web Services (AWS). CloudFront is their CDN service and they have an awesome feature that lets you host your files on your server and then Amazon automatically grabs the files from your server and puts them on their CDN. This makes it possible to easily modify your files without having

    Posted by Judy Alvarez Posted on February 28, 2022March 1, 2022
    0
  • Use your IIS logs with WCAT

    I just want to write this down so I do not forget it. I found this article that describes how to convert your IIS logs to a script that you can run with WCAT. http://theether.net/kb/100128 I had to change the HOST header to the script that was generated. And as you can see you can

    Posted by Judy Alvarez Posted on February 28, 2022March 1, 2022
    0
  • SEO: How the Panda update affected AlternativeTo

    This Monday we noticed a sudden drop in traffic from Google.com on AlternativeTo.net. I and my colleague have tried to figure out why all week and finally we found the answer. In the Google Webmaster Blog, there is a post about how Google is deploying its new spam filter (named “Panda”) to all English-speaking markets. And that

    Posted by Judy Alvarez Posted on February 28, 2022February 28, 2022
    0
  • Issues when you upgrade WordPress plugins and core on ISS 7.5

    I have had lots of issues with upgrading WordPress plugins and the core WordPress engine on my IIS 7.5 server. The problem has been that you try to upgrade the plugin, you get a fail notice AND the plugin is simply disabled and you lose permission to the folder where the plugin was located. Then

    Posted by Judy Alvarez Posted on February 28, 2022March 1, 2022
    0
  • Using an external SMTP server to send mail via different addresses in Gmail

    There is an awesome feature in Gmail that makes it stand out from many other webmails and it’s that you can specify an external SMTP server so that you can send mail from other e-mails. I understand this is an advanced feature that not so many people use but it has a major flaw. If

    Posted by Judy Alvarez Posted on February 28, 2022March 3, 2022
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • Debug and fix the z-index bug in IE6 and IE7
  • Signing a request to set up a custom Amazon CloudFront Distribution with C#
  • Use your IIS logs with WCAT
  • SEO: How the Panda update affected AlternativeTo
  • Issues when you upgrade WordPress plugins and core on ISS 7.5

COPYRIGHT © 2022 - Codepolice