Moeed Farooqui
Moeed Farooqui

Reputation: 3622

Calling a wordpress widget

I am having some problems while calling my news widget. It works fine when I call it in my header but didn't work in any other files like page.php, home.php. here is the simple code.

<?php  if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("news") ) : ?><?php endif; ?>

Upvotes: 2

Views: 106

Answers (2)

M Khalid Junaid
M Khalid Junaid

Reputation: 64496

You can also get the sidebar widget in you page.php calling get_sidebar which will load the sidebar-news.php if you have register the widget in news sidebar so simple call the sidebar which will load all the widgets in this sidebar

<?php get_sidebar( 'news' ); ?>

Upvotes: 0

The Alpha
The Alpha

Reputation: 146269

If you want to show the news widget using dynamic_sidebar function then try this

<?php  
    if ( function_exists('dynamic_sidebar') && dynamic_sidebar("news") ) :
    else :
     // static hard coded widgets
    endif;
?>

Upvotes: 1

Related Questions