• I am using a theme that was not widget aware. After finding a little tutorial I was able to create a funtions.php file and the widgets showed up! Yea!

    Now my problem is that I don’t know how to edit the side bar. When I go into the dashboard and look at the sidebar.php file it has all the info in it that it had before I installed the functions.php file so it looks like it is just being ignored. The RSS feed widget had a funky orange border around it and I actually tracked it down in the wp_includes/widget.php file so I’m guessing that the sidebar is being called from somewhere other than the theme folder but I don’t know where.

    Can someone help me out?

Viewing 7 replies - 1 through 7 (of 7 total)
  • To create a widget-ready sidebar, all you need to do is replace your sidebar code with this:

    <div id="sidebar">
    
    <?php
    	if(dynamic_sidebar(Sidebar)) :
    
    	else : // Do something if no widgets
    
    	endif;
    ?>
    
    </div>

    The word Sidebar there needs to match whatever you set as your sidebar name in your functions.php.

    Thread Starter kenhicks

    (@kenhicks)

    This is what is in the functions.php

    <?php
    if ( function_exists(‘register_sidebar’) )
    register_sidebar();
    ?>

    So does that mean I need to name my sidebar register_sidebar in order for the sidebar to see my changes? Or, in other words, will anything in another <div> section show up?

    Replace that code with this:

    <?php
    	register_sidebar(array(
    			'name' => 'Sidebar',
    			'before_widget' => '<div>',
    			'after_widget' => '</div>',
    			'before_title' => '<h2>',
    			'after_title' => '</h2>',
    	));
    ?>

    You can change the before and after widget stuff with whatever you like.

    Thread Starter kenhicks

    (@kenhicks)

    Ok, I did that and the sidebar looks the same, the only thing you can see is the widgets (which is not a bad thing – I’m using the Text widget to place a horizontal line between all the widgets). But the sidebar still seems to be ignoring what is in the sidebar.php file. There is all this hard coded html I put in there to more or less make the sidebar look like I wanted it to before I got the widgets going that is not showing up when you view the site. So I’m still back to not being able to edit the sidebar in the sidebar.php file.

    Well, do you want widgets or not?

    If you want a combo of stuff, then you’d need to add your other stuff either before the opening <?php tag or after the closing ?> tag in your sidebar.

    Thread Starter kenhicks

    (@kenhicks)

    Well yes, I want widgets but I want other stuff too. Just so we’re understanding each other, I have minimal skills other than basic html. This is what’s in my functions.php file:

    <?php
    	register_sidebar(array(
    			'name' => 'Sidebar',
    			'before_widget' => '<div>',
    			'after_widget' => '</div>',
    			'before_title' => '<h2>',
    			'after_title' => '</h2>',
    	));
    ?>

    This is what’s in my sidebar.php file

    <div id="sidebar">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    
    	<div class="box">
    		<h4>Site <em>Search</em></h4>
    						<form method="get" id="search" action="<?php bloginfo('home'); ?>/">
    						<input type="text" id="search_input"  name="s" size="30" value="Search..." 
    
    onclick='this.value="";' onBlur='this.value="Search..."' />
    						</form>
    
            </div>
    
    <div class="box">
                    <h4>NGOPC <em>Info</em></h4>
    <b>Pastor:</b> <a href="">David 
    
    Bass</a><p>
    <b>New Geneva OPC</b>
    101 4th St.
    Idaho Falls, ID 83401<p>
    
    <b>Phone:</b> 208-523-0196<p>
    
    <b>Service Times
    Sunday Worship:</b> 10 am
    <b>Sunday School/Fellowship Meal:</b> 12 noon
    <b>Wednesday Night Bible Study:</b> 7 pm
            </div>
    
    <div class="box">
    		<h4>Recent <em>Postings</em></h4>
    			<ul class="postList">
    						<?php
    						$posts = get_posts('numberposts=10&offset=0');
    						foreach($posts as $post) :
    						?>
    
    <li><a>"><?php the_title() ?>
    						<span class="listMeta"><?php the_time('g:i a') ?>, <?php the_time('F') ?> 
    
    <?php the_time('j') ?>, <?php the_time('Y') ?></span></a></li>
    						<?php endforeach; ?>
    
    	</div>
    
    <div class="box">
    		<h4>Recent <em>Comments</em></h4>
    			<?php mdv_recent_comments(); ?>
    	</div>
    
    <div class="box">
                    <h4>Reformed <em>Links</em></h4>
    <a href="https://www.opc.org/">Orthodox Presbyterian Church</a>
    
    <a href="https://opc.org/committee_wwo.html">OPC Worldwide Outreach</a>
    
    <a href="https://opc.org/wcf.html">The Westminster Confession of 
    
    Faith</a>
    
    <a href="https://www.gnpcb.org/esv/">Searchable Bible (ESV)</a>
    
    <a href="https://canonpress.org/shop">Canon Press</a>
    
    <a href="https://www.castlechurch.org/">Castle Church</a>
    
    <a href="https://reformedliterature.com/">Reformed Theology 
    
    Literature</a>
    
    <a href="https://whitehorseinn.org/">The White Horse Inn</a>
    
    <a href="https://www.credenda.org/">Credenda Agenda Magazine</a>
    
    <a href="https://theschoolofhardknox.wordpress.com/">The School of Hard Knox 
    
    Blog</a>
    
    <h4>Not-So-Reformed <em>Links</em></h4>
    
    <a href="https://loveacceptforgive.wordpress.com/">Love, Acceptance, Forgiveness 
    
    Blog</a>
    </div>
    
    <div class="box">
    <p width="100%" align="center"><embed pluginspage="https://www.adobe.com/go/getflashplayer" 
    
    src="https://www.yourminis.com/Dir/GetContainer.api?uri=yourminis/yourminis/mini:rsscontainer"  wmode="transparent" 
    
    width="230" height="170" 
    
    FlashVars="appparam=http%3A%2F%2Fwww%2Egnpcb%2Eorg%2Fesv%2Fshare%2Frss2%2E0%2Fdaily%2F&auth=&numberlines=9&subtext=1&inlin
    
    e=0&tooltips=0&newwindow=1&fontsize=12&color=13621243&uri=yourminis%2Fyourminis%2Fmini%3Arsscontainer&swfurl=%2Fwidget%5Fr
    
    sscontainer%2Eswf&width=200&xwidth=210&height=160&xheight=170&title=Daily%20Verse%20%28ESV%29&" 
    
    type="application/x-shockwave-flash" allowScriptAccess="always"></embed></p>
    </div>
    
    <div class="box">
    <p width="100%" align="center"><embed pluginspage="https://www.adobe.com/go/getflashplayer" 
    
    src="https://www.yourminis.com/Dir/GetContainer.api?uri=yourminis/yourminis/mini:rsscontainer"  wmode="transparent" 
    
    width="230" height="170" 
    
    FlashVars="inlineview=true&fontsize=12&color=13621243&appparam=http%3A%2F%2Fwww%2Eligonier%2Eorg%2Frss%2Flisten%2Erss&auth
    
    =&numberlines=9&subtext=1&inline=0&tooltips=0&newwindow=1&uri=yourminis%2Fyourminis%2Fmini%3Arsscontainer&swfurl=%2Fwidget
    
    %5Frsscontainer%2Eswf&width=200&xwidth=210&height=160&xheight=170&title=Ligoniers%20Ministries&" 
    
    type="application/x-shockwave-flash" allowScriptAccess="always"></embed></p>
    </div>
    
    <?php endif; ?>
    </div>

    When you look at my site all that you see are the active widgets and nothing that is in the code above. I like that I can use widgets now but I would also like to do a little editing for appearances sake. Sorry that I am so dense but what EXACTY should my functions.php and sidebar.php files look like so that the widgets are active and yet I can add stuff (like a <div class=”box”> so there is a box around objects)?

    Once again, sorry that I am dense but if you could help me out with this I would GREATLY appreciate it.

    Thread Starter kenhicks

    (@kenhicks)

    Ok, I got it working. Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Editing dynamic sidebar’ is closed to new replies.