Solved

wordpress widget placement

Posted on 2013-12-15
3
339 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

12 Experts available now in Live!

Get 1:1 Help Now