-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustom-section.php
More file actions
58 lines (44 loc) · 1.7 KB
/
Copy pathcustom-section.php
File metadata and controls
58 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Step 1: Prepare Code Snippets
# To add code to your header, use this code snippet:
/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
?>
PASTE HEADER CODE HERE
<?php
};
# To add code to your footer, use this code snippet:
/* Describe what the code snippet does so you can remember later on */
add_action('wp_footer', 'your_function_name');
function your_function_name(){
?>
PASTE FOOTER CODE HERE
<?php
};
#Registering Sidebars or Widget Areas in WordPress
If you want to add or register sidebars to your website without plugin.
Then paste the code given below in your functions.php file located at
website_root_path/wp-content/themes/your_theme/functions.php
<?php
function rmc_sidebar_init() {
register_sidebar( array(
'name' => __( 'Your Sidebar Name', 'wpb' ),
'id' => 'your-sidebar-1',
'description' => __( 'This is your sidebar description.', 'rmc' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'rmc_sidebar_init' );
?>
# Adding or Showing Dynamic Sidebars in WordPress Template or Theme Files
For example we want to show sidebar in our all pages.
Then paste the code given below in your page.php file located at
website_root_path/wp-content/themes/your_theme/page.php where you want your sidebar.
<?php if ( is_active_sidebar( 'your-sidebar-1' ) ) : ?>
<div id="your-sidebar" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'your-sidebar-1' ); ?>
</div>
<?php endif; ?>