• Hello,

    I went in to make some changes to the 2nd sidebar on my blog (far-right sidebar), but when I go to “Widgets” I’m unable to access the widgets on this sidebar. I think I’ve discovered the problem, but I have not idea how to solve it.

    Under “Current Widgets” my dropdown menu shows 3 options: Sidebar 1, Sidebar 1, Sidebar 2. The first option “Sidebar 1” (the first occurance) lists correctly the 4 widgets I have in this sidebar. the second option “Sidebar 1” (the second occurance) states “You are using 4 widgets in the “Sidebar 1″ sidebar. Add more from the Available Widgets section.” BUT the 4 widgets DO NOT appear below the dropdown, like they should.

    The final option, “Sidebar 2” states “You are using 0 widgets in the “Sidebar 2″ sidebar. Add more from the Available Widgets section.”

    I’m assuming the problem is that in the Theme Editor my sidebar pages are listed as Sidebar (sidebar.php) and rightbar.php (rightbar.php)–since the name is not sidebar2, is this causing my problem? If so, what’s the best way to correct this?

    Any help with this problem is greatly appreciated. If I need to display some code, or you need more info, please let me know.

    Thanks!

    The Web-Betty Blog

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter web-betty

    (@web-betty)

    Hi again,

    New day, new forum viewers. Anyone have any thoughts on my problem?

    Thanks!

    Melissa

    Thread Starter web-betty

    (@web-betty)

    Good morning! Still looking for help here…

    I think all the sidebar is register properly, it just a matter how you call (& include) the sidebar inside the template.

    Can you show the code for sidebar.php & rightbar.php? pastebin

    Thread Starter web-betty

    (@web-betty)

    Good morning (here anyway) ?? and thanks for the reply. Here’s the sidebar.php code:

    <div id="sidebar">
    <ul>
    
    <!-- Dynamic Sidebar (Widgets) -->
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    
    <!-- Search -->
    <?php include(TEMPLATEPATH . '/sidebar/search.php'); ?>
    
    <!-- Sidestep -->
    <?php if ( is_single() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/sidestep.php'); ?><?php } ?>
    
    <!-- The Pages -->
    <?php include(TEMPLATEPATH . '/sidebar/pages.php'); ?>
    
    <!-- The Categorys -->
    <?php include(TEMPLATEPATH . '/sidebar/categories.php'); ?>
    
    <!-- Neue Kommentare -->
    <?php if ( is_home() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/last.php'); ?><?php } ?>
    
    <!-- Tag Cloud -->
    <?php include(TEMPLATEPATH . '/sidebar/cloud.php'); ?>
    
    <!-- Blog Control -->
    <?php include(TEMPLATEPATH . '/sidebar/control.php'); ?>
    
    <?php endif; ?></ul>
    <!-- End Dynamic Sidebar -->
    
    <div class="bottom">
    </div><!-- End Bottom -->
    
    </div><!-- End Sidebar -->

    Here’s the rightbar.php code:

    <div id="rightbar">
    <ul>
    
    <!-- Dynamic Sidebar (Widgets) -->
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
    
    <!-- Welcome -->
    <?php if ( is_home() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/welcome.php'); ?><?php } ?>
    
    <!-- Feeds -->
    <?php if ( is_single() || is_page() || is_archive() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/feed.php'); ?><?php } ?>
    
    <!-- Kalender -->
    <?php if ( is_archive() || is_search() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/calendar.php'); ?><?php } ?>
    
    <!-- Aktuelle Beitr?ge -->
    <?php if ( is_single()|| is_page() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/topical.php'); ?><?php } ?>
    
    <!-- The Blogroll -->
    <?php if ( is_home() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/blogroll.php'); ?><?php } ?>
    
    <!-- The Archive -->
    <?php include(TEMPLATEPATH . '/sidebar/history.php'); ?>
    
    <!-- Meist kommentiert -->
    <?php if ( is_single() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/most.php'); ?><?php } ?>
    
    <!-- Statistics -->
    <?php if ( is_archive() || is_search() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/statistics.php'); ?><?php } ?>
    
    <!-- Blogbutton -->
    <?php if ( is_home() ) { ?>
    <?php include(TEMPLATEPATH . '/sidebar/button.php'); ?><?php } ?>
    
    <?php endif; ?></ul>
    <!-- End Dynamic Sidebar -->
    
    <div class="bottom">
    </div><!-- End Bottom -->
    
    </div><!-- End Rightbar -->

    Any help is greatly appreciated. I try and troubleshoot things myself as much as possible, but this one is a little out of my element.

    I think you can change rightbar.php to sidebar-right.php as its more wordpress friendly filenaming. Then you can include it with WP default functions like the below code:

    get_sidebar('right'); // include sidebar-right.php

    Thread Starter web-betty

    (@web-betty)

    Would this mean having to find and change every instance of “rightbar” in the code? Or do I just have to change the name of the rightbar.php file, and where it’s being called from?

    Here’s the code from my theme functions (functions.php) page:

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '<li><div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<div class="title">',
            'after_title' => '</div>',
        ));
    
    	// have a look for additional widgets and activate them
    	$widgets_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_template() . '/widgets');
    	if ($widgets_dir)
    	{
    		while(($widgetFile = $widgets_dir->read()) !== false)
    		{
    			if (!preg_match('|^\.+$|', $widgetFile) && preg_match('|\.php$|', $widgetFile))
    				include(ABSPATH . '/wp-content/themes/' . get_template() . '/widgets/' . $widgetFile);
    		}
    	}
    
    function get_rightbar(){
    include (TEMPLATEPATH . "/rightbar.php");
    }
    
    if ( function_exists('register_sidebars') )  {
    
    register_sidebars(2, array(
            'before_widget' => '<li><div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<div class="title">',
            'after_title' => '</div>',
           ));
    
        function unregister_problem_widgets() {
    unregister_sidebar_widget('Search');
    unregister_sidebar_widget('Recent Comments');
    unregister_sidebar_widget('Recent Posts');
    unregister_sidebar_widget('tag_cloud');
    unregister_sidebar_widget('meta');
    unregister_sidebar_widget('links');
    unregister_sidebar_widget('calendar');
    unregister_sidebar_widget('pages');
    unregister_sidebar_widget('archives');
    }
    add_action('widgets_init','unregister_problem_widgets');
    }
    
    /* Function Change Header */
    
    define('HEADER_TEXTCOLOR', 'cedbde');
    define('HEADER_IMAGE', '%s/images/header.png'); // %s is theme dir url
    define('HEADER_IMAGE_WIDTH', 912);
    define('HEADER_IMAGE_HEIGHT', 120);
    
    function theme_admin_header_style() { ?>
    
    <style type="text/css">
    
    #headimg {
    	margin: 0px 0px 20px 0px;
    	height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
    	width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
    	background: url(<?php header_image(); ?>) no-repeat top center transparent;}
    
    	#headimg * {color: #<?php header_textcolor();?>;}
    
    #headimg #desc {
    	border: none;
    	font-size: 12px;
    	text-align: center;
    	font-variant: small-caps;
    	letter-spacing: 1px;
    	margin: 0px 0px 0px 0px;
    	padding: 0px 0px 0px 0px;
    	font-family: Verdana, Arial, Helvetica, sans-serif;}
    
    #headimg h1 {
    	text-align: center;
    	border: none;
    	font-size: 24px;
    	font-weight: normal;
    	letter-spacing: 1px;
    	font-variant: small-caps;
    	margin: 0px 0px 0px 0px;
    	padding: 40px 0px 0px 0px;
    	font-family: Verdana, Arial, Helvetica, sans-serif;}
    
    	#headimg h1 a {border: none;}
    
    </style>
    
    <?php } function theme_header_style() { ?>
    
    <style type="text/css">
    
    #header {
    	margin: 4px 0px 0px 14px;
    	text-align: right;
    	height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
    	width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
    	background: url(<?php header_image(); ?>) no-repeat top center transparent;}
    
    	#header * {color: #<?php header_textcolor();?>;}
    
    </style>
    
    <?php } if ( function_exists('add_custom_image_header') ) {
    add_custom_image_header('theme_header_style', 'theme_admin_header_style');}
    
    /*
    Plugin Name: Recent Comments Edit
    Plugin URI: https://mtdewvirus.com/code/wordpress-plugins/
    Description: Retrieves a list of the most recent comments.
    Version: 1.18
    Author: Nick Momrik
    Author URI: https://mtdewvirus.com/
    */
    
    function mdv_recent_comments_edit($no_comments = 5, $comment_lenth = 5, $before = '<li>', $after = '</li>', $show_pass_post = false, $comment_style = 0) {
        global $wpdb;
        $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE post_status IN ('publish','static') ";
    	if(!$show_pass_post) $request .= "AND post_password ='' ";
    	$request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments";
    	$comments = $wpdb->get_results($request);
        $output = '';
    	if ($comments) {
    		foreach ($comments as $comment) {
    			$comment_author = stripslashes($comment->comment_author);
    			if ($comment_author == "")
    				$comment_author = "anonymous";
    			$comment_content = strip_tags($comment->comment_content);
    			$comment_content = stripslashes($comment_content);
    			$words=split(" ",$comment_content);
    			$comment_excerpt = join(" ",array_slice($words,0,$comment_lenth));
    			$permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
    
    			if ($comment_style == 1) {
    				$post_title = stripslashes($comment->post_title);
    
    				$url = $comment->comment_author_url;
    
    				if (empty($url))
    					$output .= $before . $comment_author . ' on ' . $post_title . '.' . $after;
    				else
    					$output .= $before . "<a href='$url' rel='external'>$comment_author</a>" . ' on ' . $post_title . '.' . $after;
    			}
    			else {
    				$output .= $before . '<span class="last">' . $comment_author . ':</span> <a href="' . $permalink;
    				$output .= '" title="View the entire comment by ' . $comment_author.'">' . $comment_excerpt.' ...</a>' . $after;
    			}
    		}
    		$output = convert_smilies($output);
    	} else {
    		$output .= $before . "None found" . $after;
    	}
        echo $output;
    }
    
    /*
    Plugin Name: Most Commented Edit
    Plugin URI: https://mtdewvirus.com/code/wordpress-plugins/
    Description: Retrieves a list of the posts with the most comments. Modified for Last X days -- by DJ Chuang www.djchuang.com
    Version: 1.4
    Author: Nick Momrik
    Author URI: https://mtdewvirus.com/
    */
    
    function mdv_most_commented_edit($no_posts = 5, $before = '<li>', $after = '</li>', $show_pass_post = false, $duration='') {
        global $wpdb;
    	$request = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments";
    	$request .= " WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish'";
    	if(!$show_pass_post) $request .= " AND post_password =''";
    
            if($duration !="") { $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
    }
    
    	$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
        $posts = $wpdb->get_results($request);
        $output = '';
    	if ($posts) {
    		foreach ($posts as $post) {
    			$post_title = stripslashes($post->post_title);
    			$comment_count = $post->comment_count;
    			$permalink = get_permalink($post->ID);
    			$output .= $before . '<a href="' . $permalink . '" title="' . $post_title.'">' . $post_title . '</a> (' . $comment_count.'x)' . $after;
    		}
    	} else {
    		$output .= $before . "None found" . $after;
    	}
        echo $output;
    }
    
    // helper functions
    	$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' and post_status = 'publish'");
    		if (0 < $numposts) $numposts = number_format($numposts); 
    
    	$numcmnts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
    		if (0 < $numcmnts) $numcmnts = number_format($numcmnts);
    // ----------------
    
    /*
    Plugin Name: Post Word Count Edit
    Plugin URI: https://mtdewvirus.com/code/wordpress-plugins/
    Description: Outputs the total number of words in all posts.
    Version: 1.02
    Author: Nick Momrik
    Author URI: https://mtdewvirus.com/
    */
    
    function mdv_post_word_count_edit() {
        global $wpdb;
    	$now = gmdate("Y-m-d H:i:s",time());
    	$words = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now'");
    	if ($words) {
    		foreach ($words as $word) {
    			$post = strip_tags($word->post_content);
    			$post = explode(' ', $post);
    			$count = count($post);
    			$totalcount = $count + $oldcount;
    			$oldcount = $totalcount;
    		}
    	} else {
    		$totalcount=0;
    	}
    	echo number_format($totalcount);
    }
    
    /*
    Plugin Name: Gravatar Edit
    Plugin URI: https://www.gravatar.com/implement.php#section_2_2
    Description: This plugin allows you to generate a gravatar URL complete with rating, size, default, and border options. See the <a href="https://www.gravatar.com/implement.php#section_2_2">documentation</a> for syntax and usage.
    Version: 1.1
    Author: Tom Werner
    Author URI: https://www.mojombo.com/
    
    CHANGES
    2004-11-14 Fixed URL ampersand XHTML encoding issue by updating to use proper entity
    */
    
    function gravatar_edit($rating = false, $size = false, $default = false, $border = false) {
    	global $comment;
    	$out = "https://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email);
    	if($rating && $rating != '')
    		$out .= "&amp;rating=".$rating;
    	if($size && $size != '')
    		$out .="&amp;size=".$size;
    	if($default && $default != '')
    		$out .= "&amp;default=".urlencode($default);
    	if($border && $border != '')
    		$out .= "&amp;border=".$border;
    	echo $out;
    }
    
    ?>

    Sorry…I’m confused ??

    Thread Starter web-betty

    (@web-betty)

    Ok, I changed the file rightbar.php to sidebar-right.php, then I changed the file name in the funtions.php file to call to sidebar-right.php. While this did not break anything, it didn’t solve the problem, either. Here’s the original functions.php code that calls to the 2nd sidebar:

    function get_rightbar(){
    include (TEMPLATEPATH . "/rightbar.php");
    }
    
    if ( function_exists('register_sidebars') )  {
    
    register_sidebars(2, array(
            'before_widget' => '<li><div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<div class="title">',
            'after_title' => '</div>',
           ));
    
        function unregister_problem_widgets() {
    unregister_sidebar_widget('Search');
    unregister_sidebar_widget('Recent Comments');
    unregister_sidebar_widget('Recent Posts');
    unregister_sidebar_widget('tag_cloud');
    unregister_sidebar_widget('meta');
    unregister_sidebar_widget('links');
    unregister_sidebar_widget('calendar');
    unregister_sidebar_widget('pages');
    unregister_sidebar_widget('archives');
    }
    add_action('widgets_init','unregister_problem_widgets');
    }

    Here’s the modified functions.php:

    function get_rightbar(){
    include (TEMPLATEPATH . "/sidebar-right.php");
    }
    
    if ( function_exists('register_sidebars') )  {
    
    register_sidebars(2, array(
            'before_widget' => '<li><div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div></li>',
            'before_title' => '<div class="title">',
            'after_title' => '</div>',
           ));
    
        function unregister_problem_widgets() {
    unregister_sidebar_widget('Search');
    unregister_sidebar_widget('Recent Comments');
    unregister_sidebar_widget('Recent Posts');
    unregister_sidebar_widget('tag_cloud');
    unregister_sidebar_widget('meta');
    unregister_sidebar_widget('links');
    unregister_sidebar_widget('calendar');
    unregister_sidebar_widget('pages');
    unregister_sidebar_widget('archives');
    }
    add_action('widgets_init','unregister_problem_widgets');
    }

    The only change was to the 2nd line that calls to the file.

    What else do I need to change?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘2nd sidebar not showing up in “widgets”’ is closed to new replies.