我试图在数组中存储来自特定侧栏的小部件id。但我似乎无法完成第一部分。
我有以下数组:
$results = get_option('sidebars_widgets');
print_r($results); /* Gives me the following array */
Array
(
[orphaned_widgets_1] => Array
(
[0] => search-2
[1] => recent-posts-2
[2] => recent-comments-2
[3] => archives-2
[4] => categories-2
[5] => meta-2
)
[sidebar-footer] => Array
(
)
[wp_inactive_widgets] => Array
(
)
[sidebar-main] => Array
(
)
[Shortcodes] => Array
(
[0] => pages-2
[1] => widget-id
[2] => another-id
[3] => yet-another
)
[array_version] => 3
)然后,我希望所有Shortcodes部件id都在数组中。比如:
$shortcode_widget_id = array();
foreach { code here to put the 4 id's in the $shortcode_widget_id array }但是,如何获得只包含短代码id的列表,而不是其他的呢?
发布于 2014-01-16 09:19:15
$shortcode_array = $presentarray['Shortcodes'];
$shorcode_keys = array_keys( $shortcode_array);
print_r($shorcode_keys );这是你要找的吗?
https://stackoverflow.com/questions/21157597
复制相似问题