Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

wordpress widget placement

Posted on 2013-12-15
3
Medium Priority
?
383 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 400 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

885 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