keeping custom sidebar widget code separate (2 posts)

  1. kjfrank
    Posted 5 years ago #

    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.


  2. kjfrank
    Posted 5 years ago #

    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');

Topic Closed

This topic has been closed to new replies.

About this Topic