
如何使用WordPress钩子来提高技术性SEO
wp_get_sidebar ( $id )
wp_get_sidebar: 这个函数为一个特定的WordPress主题检索侧边栏的内容。它接受一个单一的参数–要检索的侧边栏的名称。如果该侧边栏在主题中不存在,它将返回一个空字符串。
检索具有给定ID的注册侧边栏。
function wp_get_sidebar( $id ) { global $wp_registered_sidebars; foreach ( (array) $wp_registered_sidebars as $sidebar ) { if ( $sidebar['id'] === $id ) { return $sidebar; } } if ( 'wp_inactive_widgets' === $id ) { return array( 'id' => 'wp_inactive_widgets', 'name' => __( 'Inactive widgets' ), ); } return null; }