How Can We Help?

הקצאת איזורים דינמיים ליישומונים בוורדפרס

You are here:
< Back

כיצד להקצות איזורים דינמיים ליישומונים widgets בוורדפרס

בקובץ functions.php – עדיף בתבנית הבת

if ( function_exists ('register_sidebar')) {
register_sidebar(array(
'name' => 'My Sidebar',
'id' => 'sidebar1',
'description' => 'This is the main sidebar',
'before_widget' => '<div class="widget %1$s">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>'
)
);
}

בקובץ התבנית, לדוגמא בקובץ index.php נשים את הקוד המשלים הבא במקום שבו נרצה שיופיע איזור הווידג'טים הספציפי.

<?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar1' ); ?>
</div>
<?php endif; ?>

כעת, לאחר שמירה, יופיע איזור היישומונים sidebar1 באיזור היישומונים ונוכל להוסיף אליו יישומון.

Table of Contents