added widgets to front page, ordered functions files

This commit is contained in:
jorge-vitrubio 2022-12-23 18:47:19 +01:00
parent 21b46b335f
commit 24be03b427
4 changed files with 68 additions and 37 deletions

View File

@ -72,16 +72,17 @@ function ofisuport_setup() {
); );
// Set up the WordPress core custom background feature. // Set up the WordPress core custom background feature.
add_theme_support( //
'custom-background', //add_theme_support(
apply_filters( // 'custom-background',
'ofisuport_custom_background_args', // apply_filters(
array( // 'ofisuport_custom_background_args',
'default-color' => 'ffffff', // array(
'default-image' => '', // 'default-color' => 'ffffff',
) // 'default-image' => '',
) // )
); // )
//);
// Add theme support for selective refresh for widgets. // Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'customize-selective-refresh-widgets' );
@ -94,8 +95,11 @@ function ofisuport_setup() {
add_theme_support( add_theme_support(
'custom-logo', 'custom-logo',
array( array(
'height' => 250, //'height' => 250,
'width' => 250, //'width' => 250,
// not square but rectangle as XarxaProd proportions
'height' => 252,
'width' => 125,
'flex-width' => true, 'flex-width' => true,
'flex-height' => true, 'flex-height' => true,
) )
@ -120,20 +124,23 @@ add_action( 'after_setup_theme', 'ofisuport_content_width', 0 );
* *
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/ */
function ofisuport_widgets_init() {
register_sidebar( require get_template_directory() . '/inc/widgets-register.php';
array(
'name' => esc_html__( 'Sidebar', 'ofisuport' ), //function ofisuport_widgets_init() {
'id' => 'sidebar-1', // register_sidebar(
'description' => esc_html__( 'Add widgets here.', 'ofisuport' ), // array(
'before_widget' => '<section id="%1$s" class="widget %2$s">', // 'name' => esc_html__( 'Sidebar', 'ofisuport' ),
'after_widget' => '</section>', // 'id' => 'sidebar-1',
'before_title' => '<h2 class="widget-title">', // 'description' => esc_html__( 'Add widgets here.', 'ofisuport' ),
'after_title' => '</h2>', // 'before_widget' => '<section id="%1$s" class="widget %2$s">',
) // 'after_widget' => '</section>',
); // 'before_title' => '<h2 class="widget-title">',
} // 'after_title' => '</h2>',
add_action( 'widgets_init', 'ofisuport_widgets_init' ); // )
// );
//}
//add_action( 'widgets_init', 'ofisuport_widgets_init' );
/** /**
* Enqueue scripts and styles. * Enqueue scripts and styles.

32
inc/widgets-register.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registerin g-a-sidebar
*/
function ofisuport_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Front Page - principal', 'ofisuport' ),
'id' => 'front-page-widgets',
'description' => esc_html__( 'Add widgets here.', 'ofisuport' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'ofisuport' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'ofisuport' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
}
add_action( 'widgets_init', 'ofisuport_widgets_init' );

View File

@ -17,7 +17,7 @@ get_header();
<main id="primary" class="site-main"> <main id="primary" class="site-main">
<?php <?php
//if ( have_posts() ) : if ( have_posts() ) :
while ( have_posts() ) : while ( have_posts() ) :
the_post(); the_post();
@ -33,7 +33,7 @@ get_header();
endif; endif;
?> ?>
<?php <?php
//endif; // End if have_post. endif; // End if have_post.
?> ?>
<?php <?php

View File

@ -10,13 +10,5 @@
?> ?>
<aside id="destacats" class=""> <aside id="destacats" class="">
<header class="entry-header"> <?php dynamic_sidebar( 'front-page-widgets' ); ?>
<h2>Destacats</h2>
</header><!-- .entry-header -->
<div class="entry-content">
<p> cadascuna de les entrades</p>
</div><!-- .entry-content -->
<footer class="entry-footer">
</footer><!-- .entry-footer -->
</aside> </aside>