WordPress load sidebar template tag: get_ sidebar

WordPress template tag get_ Sidebar is used to load sidebar templates, namely sidebar.php

get_sidebar( string $name = null )

get_ Sidebar tags are loaded by default sidebar.php But you can pass a parameter to load a similar sidebar- name.php Template for:

<?php get_sidebar('name'); ?>

The above example loads sidebar- name.php , if sidebar- name.php If the file does not exist, it will be loaded sidebar.php

For a three column layout, we need two sidebars, sidebar- left.php And sidebar- right.php The corresponding code is as follows:

<?php get_header(); ?>
<?php get_sidebar( 'left' ); ?>
<?php get_sidebar( 'right' ); ?>
<?php get_footer(); ?>

get_ Usage and get of sidebar function_ The header function is the same. For more usage, please read:

WordPress template tag: get_ header

Extended reading

get_ The sidebar() function is located in: WP includes / general- template.php

Related Tags:

  • get_ header()
  • get_ template_ part()
  • get_ search_ form()
  • comments_ template()
  • get_ footer()
Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image