Solved

wordpress widget placement

Posted on 2013-12-15
3
337 Views
Last Modified: 2014-01-21
I am building this website from a theme...       and in the theme there is a widget for a search that shows up on the sidebar.   But I really want to put that search widget into my header.   I am read somewhere about using shortcodes or something like that??    Can i put that widget into my header???  

Here is my site...

http://ckseniorstest.jadeddesigns.ca/

Rich
0
Comment
Question by:cookmyster
3 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 100 total points
ID: 39720834
You can add a widget area to any theme section by adding code to your theme's functions.php file and adding the call to the widget area in the theme template file.

So to register a new widget area you add:

<?php
/**
 * Register our sidebars and widgetized areas.
 *
 */
function thenew_widgets_init() {

	register_sidebar( array(
		'name' => 'New Header Area 1',
		'id' => 'new_header_1',
		'before_widget' => '<div>',
		'after_widget' => '</div>',
		'before_title' => '<h2 class="whatever">',
		'after_title' => '</h2>',
	) );
}
add_action( 'widgets_init', 'thenew_widgets_init' );
?>

Open in new window


That will create a new area in Appearance | Widgets.  In your theme, you would call it this way:

<?php if ( dynamic_sidebar('new_header_1') ) : else : endif; ?>

Open in new window


References:

http://codex.wordpress.org/Widgetizing_Themes
http://codex.wordpress.org/Widgets_API#Displaying_Widgets

-----------------------------------

FYI, this method can also serve as the answer to your other question about embedding a font size switcher:

http://www.experts-exchange.com/Web_Development/Blogs/WordPress/Q_28318870.html

Just add a new widget area to the header of that theme and use one of the WordPress accessibility widgets to add the function and call it a day.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now