Solved

wordpress widget placement

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

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.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
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 …

728 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