Using WordPress Dynamic Component
In this lesson, I will show you how we create dynamic components and how we use them.
First, open your functions.php
file in the theme you are using.
How to Add Dynamic Component?
We will create the component with the register_sidebar()
function by creating a function. We will also hook our widgets_init
function.
function register_widgets()
{
register_sidebar([
'name' => 'Archive Sidebar',
'id' => 'archive_sidebar',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
]);
}
How to Use Dynamic Component in Theme?
Just write the following codes on the page you want to show;
if (is_active_sidebar('archive_sidebar')){
dynamic_sidebar('archive_sidebar');
}
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #React
- #Class
- #centOS
- #Json
- #Text
- #API
- #URL
- #Encrypting
- #Redirect
- #Form
- #Special Characters
- #Special
- #Random
- #Generating
- #SASS
- #Version
- #Installation
- #Show
- #
- #Ajax
- #method
- #Logic For Displaying Posts
- #Key
- #DDOS
- #Default Value
- #Comment Line
- #1364 Field
- #Error
- #Abbreviation
- #QR Code Generating
- #Date
- #timeAgo
- #cURL
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Vite
- #Reading Excel Files
- #Activate
- #Reading
- #Composer
- #Autoloader
- #PSR-4
- #Insert
- #Record
- #Real Time
- #Characters
- #Socket.io
There are no comments, make the firs comment