• Resolved GeoffM1968

    (@geoffm1968)


    Using the function.php, I am having an issue with the before_title and after_title not being recognized for custom widget defined in function.php which replaces the default widget. When using default widget, it’s tags set in function.php function as expected. The before_widget and after_widget function properly with both default and customized widgets.

    The code below in case I am missing anything or this is a bug. Any ideas?

    To customize widget coding for before/after tags as found in function.php prior to customized widgets:

    <?php
    	if ( function_exists('register_sidebar') )
    		register_sidebar(array(
    			'before_widget' => '<div id="%1$s" class="sideblock?%2$s">',
    			'after_widget' => '</div>',
    			'before_title' => '<h3>',
    			'after_title' => '</h3>',
    		));
    	?>

    To replace the default Search Widget found in function.php after the above code:

    <?php
    function widget_mytheme_search() {
    ?>
    	<?php echo $before_widget; ?>
    		<?php echo $before_title . 'Search' . $after_title; ?>
    		customized code here
    	<?php echo $after_widget; ?>
    <?php
    }
    if ( function_exists('register_sidebar_widget') )
    	register_sidebar_widget(__('Search'), 'widget_mytheme_search');
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter GeoffM1968

    (@geoffm1968)

    Correction: the before_widget and after widgets are not working either for customized widgets overwriting defaults.

    Source of code in question for rendered page:

    Search
    <div id="categories-3" class="sideblock?widget_categories"><h3>Categories</h3>		<ul>cut code</ul>
    </div>

    Thread Starter GeoffM1968

    (@geoffm1968)

    Figured it out. Adding optional name and id variables fixed it:

    <?php
    if ( function_exists('register_sidebar') )
    	register_sidebar(array(
    		'name' => '%1$s',
    		'id' => 'sidebar-%1$s',
    		'before_widget' => '<div id="%1$s" class="sideblock?%2$s">',
    		'after_widget' => '</div>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3>',
    	));
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Widget Customizing Issue with Replaced Widgets for before_title and after title’ is closed to new replies.