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.
add_theme_support(
'custom-background',
apply_filters(
'ofisuport_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
//
//add_theme_support(
// 'custom-background',
// apply_filters(
// 'ofisuport_custom_background_args',
// array(
// 'default-color' => 'ffffff',
// 'default-image' => '',
// )
// )
//);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
@ -94,8 +95,11 @@ function ofisuport_setup() {
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
//'height' => 250,
//'width' => 250,
// not square but rectangle as XarxaProd proportions
'height' => 252,
'width' => 125,
'flex-width' => 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
*/
function ofisuport_widgets_init() {
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' );
require get_template_directory() . '/inc/widgets-register.php';
//function ofisuport_widgets_init() {
// 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' );
/**
* 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">
<?php
//if ( have_posts() ) :
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
@ -33,7 +33,7 @@ get_header();
endif;
?>
<?php
//endif; // End if have_post.
endif; // End if have_post.
?>
<?php

View File

@ -10,13 +10,5 @@
?>
<aside id="destacats" class="">
<header class="entry-header">
<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 -->
<?php dynamic_sidebar( 'front-page-widgets' ); ?>
</aside>