• achaninusa

    (@achaninusa)


    I have googled and read thru multiple guides, mostly same instructions, but I still can’t create a customized sidebar to load widgets on my static Home page (i.e. the landing page ending in “/”). Right now, I can see the sidebar in Appearance->Widgets, but I can’t load images into the sidebar.

    I am not trying to become a WP developer, I am just trying to create asimple web site with customized sidebars for infographic slides, one sidebar for each page.

    Right now, I have “trashed” Home and recreating it.

    Here are the codes I added to functions.php to register homepage_sidebar:
    [code]
    /**
    * AC: added 'Homepage_Sidebar', visible in Appearance->Widgets but not loading widgets
    */

    function twentyeleven_widgets_init() {

    register_widget( 'Twenty_Eleven_Ephemera_Widget' );

    register_sidebar(
    array(
    'name' => __( 'Homepage_Sidebar', 'twentyeleven' ),
    'id' => 'homepage_sidebar',
    'description' => __( 'Optional 20-11 Template', 'twentyeleven' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>'
    )
    );
    }
    add_action( 'widgets_init', 'twentyeleven_widgets_init' );
    [/code]

    And here are the codes I added to sidebar.php
    I added the check is_home() b/c I only want it to show on Home page.

    <?php
    /**
    * Sidebar containing the main widget area
    *
    * @package WordPress
    * @subpackage Twenty_Eleven
    * @since Twenty Eleven 1.0
    */

    $options = twentyeleven_get_theme_options();
    $current_layout = $options[‘theme_layout’]; ?>

    <div class=”sidebar homepage_sidebar”>

    <?php if ( is_home() && is_active_sidebar(‘homepage_sidebar’)) : ?>
    <div id=”sidebar”>
    <?php echo(‘homepage_side is active if you see this line.’); ?>
    <?php dynamic_sidebar(‘homepage_sidebar’); ?>
    </div>
    <?php else :?>
    <!– display archives and some meta data like login –>
    <aside id=”archives” class=”widget”>
    <h3 class=”widget-title”><?php _e( ‘Archives’, ‘twentyeleven’ ); ?></h3>

      <?php wp_get_archives( array( ‘type’ => ‘monthly’ ) ); ?>

    </aside>
    <aside id=”meta” class=”widget”>
    <h3 class=”widget-title”><?php _e( ‘Meta’, ‘twentyeleven’ ); ?></h3>

      <?php wp_register(); ?>

    • <?php wp_loginout(); ?>
    • <?php wp_meta(); ?>

    </aside>
    <?php endif; ?>

    </div>`

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Rather than using separate sidebar per page, use a plugin like “Widget Context” to define what widgets appear on which pages.

    is_home is tricky… you probably want to use is_front_page. See https://developer.wordpress.org/reference/functions/is_front_page/ “is_home” refers to the site’s blog page: https://developer.wordpress.org/reference/functions/is_home/

    Thread Starter achaninusa

    (@achaninusa)

    I came across this while clicking thru the WP site, does it mean I should modify the sidebar-page.php instead instead of sidebar.php

    Incidentally, I haven’t found the toggle for static page yet.

    How to insert an image here, it would add to clarity?

    Thread Starter achaninusa

    (@achaninusa)

    @sterndata
    Okay, I’ll restore the original codes for functions.php and sidebar.php
    I haven’t had much success using plugins.
    Also, I do not want sidebars on most pages and not on post, just on 2 pages, each with its own customized side bar

    • This reply was modified 5 years ago by achaninusa.
    Thread Starter achaninusa

    (@achaninusa)

    Have you tried Simple Page Sidebars?

    I don’t see why I cannot leave the new sidebar I have created in there even if I use a plugin.

    • This reply was modified 5 years ago by achaninusa.
    Thread Starter achaninusa

    (@achaninusa)

    WP cannot find the sidebar plugin, trying several others..
    I have spent over 2 weeks just on WP sidebars

    Thread Starter achaninusa

    (@achaninusa)

    Nope, none of the plugins work as advertised.

    For example https://www.blogsuccessjournal.com/how-to-create-sidebars-in-wordpress/
    says install, hover over Appearance->Widget and click on “Create a New Sidebar”. No such thing on the screen.

    Just got to find a plugin that works and come with instructions.

    Thread Starter achaninusa

    (@achaninusa)

    Ahh, I think I still have to insert my codes for customized sidebars, the plugins will see them and assign them to the page.
    And “Main Sidebar” is not the name of an existing sidebar, it is a sidebar that I want to become the main sidebar. But what is the “Showcase Sidebar”?
    I’ll try that, I’ve tried everything else

    • This reply was modified 5 years ago by achaninusa.
Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Help with PHP codes for sidebar – not loading widgets!’ is closed to new replies.