the_widget() and widget’s ID

I believe @One Trick Pony was right. Shortcode widgets have no ID, so I’ve found a way around. Firstly I used PHP rand function: $var = rand(); And then added the “var” to the ID, so it doesn’t collide with other shortcodes calling the same widget (each one has different random number at the end … Read more

Add custom post types stats to a custom dashboard widget

Lokks like you have a function declared inside another function, your code is wrong, try this: // wp_dashboard_setup is the action hook add_action(‘wp_dashboard_setup’, ‘mycustom_moviestats’); // add dashboard widget function mycustom_moviestats() { wp_add_dashboard_widget(‘custom_movie_widget’, ‘Movie Stats’,’custom_dashboard_movie_list’); } function custom_dashboard_movie_list(){ $args = array( ‘public’ => true , ‘_builtin’ => false ); $output=”object”; $operator=”and”; echo ‘<table>’; //loop over all … Read more

Custom Menus, Widgets & Conditional Statements

if you want to show the menus only on child pages then you need to change your conditional statement: global $post; //only on children of 269 if (‘269’ == $post->post_parent){ //menu for Sport & Fitness pages ?> <div id=”seventh” class=”widget-area” role=”complementary”> <?php dynamic_sidebar( ‘sidebar-7’ ); ?> </div><!– #second .widget-area –> <?php //only on children of … Read more

How to rename wordpress Widget

The classes assigned to rendered Widgets are specified by the argument array passed to the register_sidebar() call used to register the sidebar. e.g.: <?php $args = array( ‘name’ => sprintf(__(‘Sidebar %d’), $i ), ‘id’ => ‘sidebar-$i’, ‘description’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ … Read more

Pass variables from one widget to another widget

You don’t need to make it global. If your include a file from within a functions scope, any variables that you defined in that function (before that point) will be exposed in the included file as well. But because the variable you are talking about represents the state of the footer file inclusion (if I … Read more