Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

wordpress widget placement

Posted on 2013-12-15
3
Medium Priority
?
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
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).

721 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