wordpress enabled sidebar gadgets

http://www.seo628.com/1872.html

 

wordpress background gadgets not displayed by default option, developers need to enable the gadget to gadget functionality and call the front desk in the corresponding position, so as to generate the sidebar and drag directly in the background.

Inactive Widgets

Inactive Widgets need to register at least a sidebar in functions.php

regisyou r_sidebar( array(
'name' => __( '默认侧边栏', 'Bing' ),
'id' => 'widget_default',
'description' => __( '侧边栏的描述', 'Bing' ),
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
) );

So look at you can see the gadgets button up

wordpress enabled sidebar gadgets

Drag the gadget needs to set

Call the front desk

<?php dynamic_sidebar( 'widget_default' ); ?>

Use the_widget () function is called directly Gadgets

<?php the_widget($widget, $instance, $args); ?>

Parameters $ widget, gadget class name

  • WP_Widget_Archives - Archive Gadgets
  • WP_Widget_Calendar - Calendar Gadgets
  • WP_Widget_Ca TE gories - Category Gadgets
  • WP_Widget_Links - Links gadget
  • WP_Widget_Meta - Meta Gadgets
  • WP_Widget_Pages - Page Gadgets
  • WP_Widget_Recent_COM ments - Recent Comments widget
  • WP_Widget_Recent_Posts - Latest Articles gadgets
  • WP_Widget_RSS - RSS Gadget
  • WP_Widget_Search - Search Gadget
  • WP_Widget_Tag_Cloud - Tag Cloud widget
  • WP_Widget_ Te XT - text widget
  • WP_Nav_Menu_Widget - Menu gadgets

$ Instance parameters

Representing each widget settings, such as Archives are displayed in dropdown menu or list display

$ Args parameter

The widget Si Debar parameters, including before_widget, AF TE r_widget, BEFORE_TITLECongratulationsE_N_D__T_I_T_L_EYou and AF TE R_ARTIST

Archives calling gadget example

<?php the_widget('WP_Widget_Recent_Posts'); ?>

Guess you like

Origin blog.csdn.net/james_laughing/article/details/92390560