Forums

[resolved] Calling Widgets directly in index.php (4 posts)

  1. Will White
    Member
    Posted 2 years ago #

    I was looking at making a custom front page for my site and was hoping to reuse a widget that I have set up on the sidebar on regular pages/posts. It would be nice to only have to update one widget and have all sidebars and and front page all update together.

    The Widget: Text Widget (comes with default install)
    The Site: http://www.psychreview.net
    The Question: Is there a way to use php to call the widget in the index.php file?

    Thanks guys!

  2. Edward Caissie
    Member
    Posted 2 years ago #

    Have you tried the_widget() function?

    This post gives an explanation of how it can be used: http://wpfirstaid.com/2010/01/no-widget-area/

    The details of the default Text Widget can be found in the core files at: ../wp-includes/default-widgets.php around line 369.

  3. Will White
    Member
    Posted 2 years ago #

    Thanks for the info.

    I ended up creating a second sidebar template, and a second sidebar, and pulling in the sidebar where I wanted the widget. Kind of a round-about way of doing it, but it works.

    Definitely going to look into the_widget() though, didn't notice that in the 2.8 notes. Thanks!

  4. Edward Caissie
    Member
    Posted 2 years ago #

    You're welcome! Glad to help.

Topic Closed

This topic has been closed to new replies.

About this Topic