Support » Plugins and Hacks » Hacks » keeping custom sidebar widget code separate

  • kjfrank

    (@kjfrank)


    I would like to keep my custom widget in their own folder, separate from my functions.php file and available to all my themes, similar to the way plugins has its own folder under “wp-content/plugins”. Since it appears that wordpress only supports reading sidebar widgets from the functions.php file (I could be wrong here) does anyone see a problem with just using an includes in my functions.php file like so:

    include (content_url() . '/widgets/widget-seo/widget-name.php');
    include (content_url() . '/widgets/widget-rss/widget-name1.php');
    include (content_url() . '/widgets/widget-rss/widget-name2.php');

    to pull individual widgets while still keeping the separate widget file in a newly created folder under “wp-content” like so(“wp-content/widgets/widget-type/widget-name.php”).
    Any help or better suggestions(I am fairly new to wordpress) would be greatly appreciated.

    Thanks

Viewing 1 replies (of 1 total)
  • kjfrank

    (@kjfrank)

    realized “content_url” is incorrect I’m using “WP_CONTENT_DIR” instead so my code would read:

    include (WP_CONTENT_DIR . '/widgets/widget-seo/widget-name.php');
    include (WP_CONTENT_DIR . '/widgets/widget-rss/widget-name1.php');
    include (WP_CONTENT_DIR . '/widgets/widget-rss/widget-name2.php');
Viewing 1 replies (of 1 total)
  • The topic ‘keeping custom sidebar widget code separate’ is closed to new replies.