• Resolved vanillakelly

    (@vanillakelly)


    I’m currently coding my own one page wordpress theme (based on underscores) and I’m trying to add a widget to a page, so this widget will show up on my homepage.

    I used this page as my guide; https://codex.www.ads-software.com/Widgetizing_Themes but the widget is not showing up on my homepage.

    Steps I took:
    1. Create a custom page template, this is the code of that:

    <?php
    /*
    Template Name: Widget Page
    */
    
    get_header(); ?>
    
    	<div id="primary" class="content-area">
    
    	<?php putRevSlider("video","homepage") ?>
    
    		<main id="main" class="site-main" role="main">
    
    			<?php dynamic_sidebar( 'widget-page' ); ?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Seems to work fine, I can select the template and the content of my page shows up on the homepage. (See test widget, test test test)

    I added the line that calls on the widget there too, as you can tell.

    Then I added this to my functions.php;

    /**
     * Register our sidebars and widgetized areas.
     *
     */
    function arphabet_widgets_init() {
    
    	register_sidebar( array(
    		'name'          => 'Widget Page',
    		'id'            => 'widget-page',
    		'before_widget' => '<div>',
    		'after_widget'  => '</div>',
    	) );
    
    }
    add_action( 'widgets_init', 'arphabet_widgets_init' );

    And I think that’s where it’s going wrong? The underscores framework also comes with their own piece of widget code, is this causing problems?

    /**
     * Register widget area.
     *
     * @link https://codex.www.ads-software.com/Function_Reference/register_sidebar
     */
    function otto_widgets_init() {
    	register_sidebar( array(
    		'name'          => esc_html__( 'Sidebar', 'otto' ),
    		'id'            => 'sidebar-1',
    		'description'   => '',
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h1 class="widget-title">',
    		'after_title'   => '</h1>',
    	) );
    }
    add_action( 'widgets_init', 'otto_widgets_init' );

    This is a link to my page; https://kellyvuijst.nl/onepage/

    Thanks in advcance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Widget on page not showing up’ is closed to new replies.