Question

My dynamic sidebar does not show standard widgets like recent posts or archives but the individual content I put into the sidebar.php

This is the sidebar-part from my functions.php:

add_action( 'widgets_init', 'my_register_sidebars' );

function my_register_sidebars() {

    register_sidebar( array(
    'name'         => __( 'Primäre Sidebar' ),
    'id'           => 'sidebar-main',
    'description'  => __( 'Rechte Hauptsidebar für Werbeflächen und Meta' ),
    'before_title' => '<h4>',
    'after_title'  => '</h4>',
) );

and this is the code from sidebar.php:

<aside id="sidebar-main">
<div id="widgetarea">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : endif; ?>

<h4>TESTESTEST</h4>
<p>HALLOHALLO</p>

</div>
</aside>

As always, I call the sidebar by <?php get_sidebar(); ?> in my theme.

How come the other stuff is being displayed but not the widgets? I have no clue. Edit: I already tried deactivating plugins - no change.

Was it helpful?

Solution

Your call to your sidebar is wrong. This

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : endif; ?>

should be

<?php if ( is_active_sidebar( 'sidebar-main' ) ) : ?>

        <?php dynamic_sidebar( 'sidebar-main' ); ?>

    <?php endif; ?>

OTHER TIPS

try this in sidebar.php:

<aside id="sidebar-main">
<div id="widgetarea">

    <?php dynamic_sidebar('Primäre Sidebar') ?>

</div>
</aside>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top