在任意位置插入小工具 wordpress主题修改 让主题支持小工具
- font size decrease font size increase font size
输入以下代码到 /wp-content/theme/themename/functions.php 如果没有可以自己手动创建一个。
<?php if (function_exists('register_sidebar')) { register_sidebar(array( 'name' => '边栏1', // 侧边栏 1 的名称 'before_widget' => '<li>', // widget 的开始标签 'after_widget' => '</li>', // widget 的结束标签 'before_title' => '<h3>', // 标题的开始标签 'after_title' => '</h3>'// 标题的结束标签 )); register_sidebar(array( 'name' => '边栏2', // 侧边栏 2 的名称 'before_widget' => '<li>', // widget 的开始标签 'after_widget' => '</li>', // widget 的结束标签 'before_title' => '<h3>', // 标题的开始标签 'after_title' => '</h3>'// 标题的结束标签 )); register_sidebar(array( 'name' => '边栏3', // 侧边栏 3 的名称 'before_widget' => '<li>', // widget 的开始标签 'after_widget' => '</li>', // widget 的结束标签 'before_title' => '<h3>', // 标题的开始标签 'after_title' => '</h3>'// 标题的结束标签 )); register_sidebar(array( 'name' => '边栏4', // 侧边栏 4 的名称 'before_widget' => '<li>', // widget 的开始标签 'after_widget' => '</li>', // widget 的结束标签 'before_title' => '<h3>', // 标题的开始标签 'after_title' => '</h3>'// 标题的结束标签 )); } ?>
1之后我们只需要在想要添加小工具的地方数据以下代码。2
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('边栏名称3')): ?> <?php endif;
?>3
Last modified onSunday, 23 December 2012 14:45
( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0010 | 416392 | {main}( ) | .../index.php:0 |
2 | 0.1138 | 4722304 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1139 | 4722304 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.3597 | 12450888 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.3609 | 12475952 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.3618 | 12531280 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.3621 | 12560104 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.3736 | 12995512 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.3736 | 12995512 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.3845 | 13720712 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.3845 | 13720712 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.3904 | 14117080 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.3924 | 14137448 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.4863 | 17041504 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.4863 | 17041504 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.4890 | 17221704 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |
- Published in Wordpress
- Read 3406 times
( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0010 | 416392 | {main}( ) | .../index.php:0 |
2 | 0.1138 | 4722304 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1139 | 4722304 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.3597 | 12450888 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.3609 | 12475952 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.3618 | 12531280 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.3621 | 12560104 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.3736 | 12995512 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.3736 | 12995512 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.3845 | 13720712 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.3845 | 13720712 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.3904 | 14117080 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.3924 | 14137448 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.4863 | 17041504 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.4863 | 17041504 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.4890 | 17221704 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |