我正在基于主题构建一个儿童主题。
我不想使用小部件,而是想硬编码我的侧边栏,但我不知道如何做到这一点。
感谢您的帮助!
谢谢
我正在基于主题构建一个儿童主题。
我不想使用小部件,而是想硬编码我的侧边栏,但我不知道如何做到这一点。
感谢您的帮助!
谢谢
你可以。。。
1. Enter your sidebar.php file and remove everything..
(better to just remove the code that calls the widigtized sidebar see examples)
<?php if ( function_exists(\'dynamic_sidebar\') && dynamic_sidebar(\'pages\') ) : else : ?><?php endif; ?>
示例2(可能也是这样):<?php wp_nav_menu( array( \'theme_location\' => \'primary-menu\' ) ); ?>
假设您想显示最新的帖子。。您需要更正代码:
<h2>Recent Posts</h2>
<ul>
<?php
$recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
echo \'<li><a href="\' . get_permalink($recent["ID"]) . \'" title="Look \'.$recent["post_title"].\'" >\' . $recent["post_title"].\'</a> </li> \';
}
?>
</ul>
(来源:http://codex.wordpress.org/Function_Reference/wp_get_recent_posts)。这将检索最近帖子的列表
通过这种方式,您可以在侧栏中构建侧栏的部分内容。php文件,或者希望将哪个文件作为边栏文件包含在模板中。
创建另一个包含所有自定义内容的PHP文件(我们称之为custom_sidebar.php ). 然后在页面/模板上包括(或替换侧边栏.php)以下行(在需要内容的地方):
<?php get_template_part( \'custom_sidebar\' ); ?>
您只需删除。php后缀(如上所述)。推特刚刚发布了一个new web framework called Bootstrap. 在主题中使用它的正确方式是什么?Update: 样式表包含确实很简单。我想知道应该注意哪些注意事项或兼容性问题。