您现在的位置是:首页 > 网站制作 > WordpressWordpress
WordPress函数 get_sidebar()
杰帅2023-08-19【Wordpress】人已围观
简介介绍
介绍
主题边栏模板调用函数,可以调用一些特别的边栏"sidebar-special.php",如这样。
参数
$name
(string) (Optional) The name of the specialised sidebar.
Default value: null
示例
调用你主题中 wp-content/yourTheme/sidebar-nice-bar.php 文件,可以使用
<?php get_sidebar('nice-bar'); ?>
多个不同的边栏
<?php
if ( is_home() ) :
get_sidebar( 'home' );
elseif ( is_404() ) :
get_sidebar( '404' );
else :
get_sidebar();
endif;
?>
首页显示 sidebar-home.php的内容,404页面显示 sidebar-404.php的内容,其他页面显示 sidebar.php的内容。
一个简单的404页面
<?php get_header(); ?>
<h2>Error 404 - Not Found</h2>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Tags:wordpress函数 侧边栏
很赞哦! ()
相关文章
随机图文
如何将WordPress文章迁移到Shopify:使用WP All Export插件的完整指南
如果您正在将WordPress网站迁移到Shopify,并希望将文章内容一起迁移,WP All Export插件是一个理想的解决方案。通过这款插件,您可以轻松导出WordPress中的文章,并将其转换为适合Shopify的CSV格式。WordPress 页面模板(Page Template)下拉列表不显示的原因及解决方法
WordPress 的自定义页面模板是一个非常强大好用的功能,使用它新建一些静态页面(Page),添加上一些数据调用的函数,再在网页上做一个导航连接到对应的页面就可以实现很多自定义的功wp_reset_postdata 和 wp_reset_query 的作用与区别
什么时候使用wp_reset_query,什么时候用wp_reset_postdata?wordpress 上传的图片不显示的问题 base64,data:image/gif