Forums

WP adding '-2' to ID names in my Sidebar (5 posts)

  1. larrychartier
    Member
    Posted 3 months ago #

    Hoping someone can help me with this...

    For some reason WP is adding '-2' to my some of my sidebar ID's. Here is one example...It should read:

    '<li id="search" class="widget widget_search">'

    Somewhere along the way it changed to:

    '<li id="search-2" class="widget widget_search">'

    I'm not exactly sure why it is doing this as I haven't touched anything in the sidebar code. If anyone has any ideas or solutions to stop this from happening I would really appreciate it.

    Thanks in advance!

  2. esmi
    Member
    Posted 3 months ago #

    Since you're using widgets, the relevant ids and classes will be defined in your theme's functions.php file.

  3. craigwann
    Member
    Posted 2 months ago #

    Same issue. Worpress is adding an extra "-2" to my search tag, giving me id="search-2". I have checked my functions.php file, but I am unable to find a solution.

    This first happened after I updated to 2.8. I was not having this issue before the update.

    @larrychartier - As a temporary fix, you might try changing the "#sidebar #search" style in your css file to "#sidebar #search-2". That's what I did.

    This is driving me nuts!

    Here is the search portion of my functions.php file.

    // Widget: Search; to match the theme style and replace Widget plugin default
    function widget_sandbox_search($args) {
    	extract($args);
    	$options = get_option('widget_sandbox_search');
    	$title = empty($options['title']) ? __( '', 'sandbox' ) : $options['title'];
    	$button = empty($options['button']) ? __( 'search', 'sandbox' ) : $options['button'];
    ?>
    			<?php echo $before_widget ?>
    				<form id="mainsearch" method="get" action="<?php bloginfo('home') ?>">
    	<div>
    		<input id="s" class="text-input" name="s" type="text" value="looking for something?" onfocus="if (this.value == 'looking for something?') {this.value = '';}" onblur="if (this.value == '') {this.value = 'looking for something?';}"  tabindex="1" />
    		<input id="searchsubmit" name="searchsubmit" type="image" src="<?php bloginfo('template_directory'); ?>/imgs/btn-search.gif" alt="search" tabindex="2" />
    	</div>
    </form>
    			<?php echo $after_widget ?>
    <?php
    }

    AND

    // Finished intializing Widgets plugin, now let's load the Sandbox default widgets; first, Sandbox search widget
    	$widget_ops = array(
    		'classname'    =>  'widget_pages',
    		'description'  =>  __( "Your blog's WordPress Pages (Autumn Forest)", "sandbox" )
    	);
    	wp_register_sidebar_widget( 'pages', __( 'Pages', 'sandbox' ), 'widget_sandbox_pages', $widget_ops );
    	unregister_widget_control('pages');
    	wp_register_widget_control( 'pages', __( 'Pages', 'sandbox' ), 'widget_sandbox_pages_control' );
    
    	$widget_ops = array(
    		'classname'    =>  'widget_search',
    		'description'  =>  __( "A search form for your blog (Autumn Forest)", "sandbox" )
    	);
    	wp_register_sidebar_widget( 'search', __( 'Search', 'sandbox' ), 'widget_sandbox_search', $widget_ops );
  4. shoshanna
    Member
    Posted 2 weeks ago #

    Has anyone found out why this is happening yet?

  5. konspire
    Member
    Posted 1 week ago #

    Just realized I am dealing with the same problem. What seems to be the cause of this?

Reply

You must log in to post.

About this Topic