Hello,
I'm using the "shaken grid premium theme", and i would like to place a newsletter widget (by mailchimp) in the header. I should make a change in the header.php.
Can anyone help me with this?
Thank you for the help!
greetings, karina
This is the header.php
<?php
/**
* Header Template
*
* This file is responsible for generating the
* top-most html for all public-facing views.
* It's content is generated via core WordPress
* functions as well as custom actions defined
* in functions.php.
*
* Child themes are encouraged to work with the
* actions defined herein to add or remove data
* to/from the top of the template. In the event
* that the html needs to be modified, this
* template may be duplicated inside a child theme
* and edited there.
*
* @package Shaken Grid (Premium)
* @since 1.0
* @alter 1.6
*
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'shaken' ), max( $paged, $page ) );
?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/js/colorbox/colorbox.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/ie.css" />
<![endif]-->
<?php /* Alternate Stylesheet selected in Theme Options */
if(of_get_option('alt_stylesheet') && of_get_option('alt_stylesheet') != "default")
{ ?>
<link rel='stylesheet' type='text/css' href="<?php echo get_template_directory_uri(); ?>/skins/<?php echo of_get_option('alt_stylesheet'); ?>.css" media="screen" />
<?php } ?>
<?php /* Custom styles set in Theme Options */ ?>
<link rel='stylesheet' type='text/css' href="<?php bloginfo('url'); ?>/?shaken-custom-content=css" media="screen" />
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/custom.css" />
<?php wp_head(); ?>
<?php // @font-face (Google Web Fonts)
if(!of_get_option('disable_fontface')): ?>
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Yanone Kaffeesatz:regular,bold' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
<?php endif; ?>
<?php /* Insert Analytics Code set in Theme Options (Option deprecated in 1.6.0 - Use a plugin instead) */
if(get_option('shaken_analytics_code')){ echo get_option('shaken_analytics_code'); } ?>
</head>
<body <?php body_class(); ?>>
<!-- =================================
Header and Nav
================================= -->
<div id="header">
<?php /* Logo and Tagline */ ?>
<div id="site-info">
<?php if(of_get_option('logo')) { ?>
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<img src="<?php echo of_get_option('logo'); ?>" alt="<?php bloginfo( 'name' ); ?> | <?php bloginfo( 'description' ); ?>" title="<?php bloginfo( 'name' ); ?>" id="logo" />
</a>
<?php } else { ?>
<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
<<?php echo $heading_tag; ?> id="logo">
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
</<?php echo $heading_tag; ?>>
<div id="site-description"><?php bloginfo( 'description' ); ?></div>
<?php } ?>
</div><!-- #site-info -->
<?php /* Main Menu */ ?>
<div class="header-nav">
<?php wp_nav_menu( array('theme_location' => 'header' ) ); ?>
</div>
<?php /* Social network links set in Theme Options */ ?>
<div id="social-networks">
<?php if(of_get_option('twitter')){ ?>
<a href="http://twitter.com/<?php echo of_get_option('twitter'); ?>" title="Tweets" class="twitter">Twitter</a>
<?php }
if(of_get_option('facebook')){ ?>
<a href="<?php echo of_get_option('facebook'); ?>" title="Facebook" class="facebook">Facebook</a>
<?php }
if(of_get_option('youtube')){ ?>
<a href="http://www.youtube.com/user/<?php echo of_get_option('youtube'); ?>" title="YouTube" class="youtube">YouTube</a>
<?php }
if(of_get_option('vimeo')){ ?>
<a href="http://www.vimeo.com/<?php echo of_get_option('vimeo'); ?>" title="Vimeo" class="vimeo">Vimeo</a>
<?php }
if(of_get_option('flickr')){ ?>
<a href="http://www.flickr.com/photos/<?php echo of_get_option('flickr'); ?>/" title="Flickr" class="flickr">Flickr</a>
<?php }
if(of_get_option('dribbble')){ ?>
<a href="http://dribbble.com/<?php echo of_get_option('dribbble'); ?>" title="Dribbble" class="dribbble">Dribbble</a>
<?php }
if(of_get_option('last_fm')){ ?>
<a href="http://www.last.fm/user/<?php echo of_get_option('last_fm'); ?>" title="last.FM" class="lastFM">last.FM</a>
<?php }
if(of_get_option('delicious')){ ?>
<a href="http://delicious.com/<?php echo of_get_option('delicious'); ?>" title="Bookmarks" class="delicious">Delicious</a>
<?php }
if(of_get_option('email')){ ?>
<a href="mailto:<?php echo of_get_option('email'); ?>" title="Email" class="email">Email</a>
<?php } ?>
<a href="<?php if(of_get_option('rss')){ echo of_get_option('rss'); } else { bloginfo('rss2_url'); }?>" title="Subscribe" class="rss">RSS</a>
</div><!-- #social-networks -->
<div class="clearfix"></div>
</div>
Marko Nikolic answers:
Hello,
add this code in header, where you want to see widget:
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Widget name')) : ?>
<?php endif; ?>
In functions.php, add this code:
if ( function_exists('register_sidebar') ) {
register_sidebar(array('name'=>'Widget name',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
}
That is basic solution. Now all you have to do is to make place in header, and to go to widget area in Admin panel, and to add widget you need.
Edit:
read these pages, too, you can find detailed info about parameters and other staff you should know:
http://codex.wordpress.org/Function_Reference/register_sidebar
http://www.themelab.com/2008/04/18/see-how-easy-it-is-to-widgetize-wordpress-themes/
Edit two:
After that, you can install this plugin:
http://wordpress.org/extend/plugins/mailchimp/
and add it in admin panel Appearance --> Widgets --> "new widget"
Karina Soors comments:
hi Marko,
thanks for the quick answer!
Can i place the code anywhere i want in the .php?
And how do i make some place in the header?
And for the widgets, in the theme 'shakengrid premium' i can not add a new widget..
thank you!
greetings
Karina
Marko Nikolic comments:
You can put it anywhere but not within other <?php ... ?>
You should have basic knowledge of HTML/CSS. When I said to make some place for it I thought about creating a div that will be used to put that widget at the place you wand (after logo, navigation, above or below...).
I haven't been using this theme, but you should have access to all files, so there shouldn't be a problem to add new widget by adding the code I pasted here.
Mila Frerichs answers:
as Romel pointed out you do not need any form of a widget. it is possible and by far the best way to add something to a theme, but the Mailchimp Plugin allows you to add the signup form anywhere.
I don't know if it's a good idea to place the sign-up form in the header, but maybe you only want to place a link to the signup form in the header. if so I would suggest you do so in the "Social Network" section
<?php /* Social network links set in Theme Options */ ?>
<div id="social-networks">
...
<strong>"Link to Signup Form"</strong>
</div><!-- #social-networks -->
Maybe you pick a Mail Logo to indicate that there will be a Newsletter.
Add a new Page to your Blog and include the following as the text:
[mailchimpsf_form]
And then link to the new created page.
juaribd answers:
Just replace the the functions.php and header.php with the code porvide here. Then install mailchimp list sign up plugin. then go to widgets. you will notify a widget space called "header". drag the mailchimp widget to "header". Thats all.
<strong>header.php</strong>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'shaken' ), max( $paged, $page ) );
?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/js/colorbox/colorbox.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/css/ie.css" />
<![endif]-->
<!-- Warchain -->
<?php // Alternate Stylesheet selected in Theme Options
if(get_option('shaken_alt_stylesheet') && get_option('shaken_alt_stylesheet') != "default")
{ ?>
<link rel='stylesheet' type='text/css' href="<?php bloginfo('template_directory'); ?>/skins/<?php echo get_option('shaken_alt_stylesheet'); ?>.css" media="screen" />
<?php } ?>
<?php // Custom styles set in Theme Options ?>
<link rel='stylesheet' type='text/css' href="<?php bloginfo('url'); ?>/?shaken-custom-content=css" media="screen" />
<?php // Plugins and Scripts ?>
<?php wp_head(); ?>
<?php // @font-face (Google Web Fonts)
if(!get_option('shaken_disable_fontface')): ?>
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Yanone Kaffeesatz:300', 'Yanone Kaffeesatz:400' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
<?php endif; ?>
<?php // Insert Analytics Code set in Theme Options
if(get_option('shaken_analytics_code')){ echo get_option('shaken_analytics_code'); } ?>
</head>
<body <?php body_class(); ?>>
<!-- =================================
Header and Nav
================================= -->
<div id="header">
<div id="site-info">
<?php if(get_option('shaken_logo')) { ?>
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<img src="<?php echo get_option('shaken_logo'); ?>" alt="<?php bloginfo( 'name' ); ?> | <?php bloginfo( 'description' ); ?>" title="<?php bloginfo( 'name' ); ?>" id="logo" />
</a>
<?php } else { ?>
<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
<<?php echo $heading_tag; ?> id="logo">
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
</<?php echo $heading_tag; ?>>
<div id="site-description"><?php bloginfo( 'description' ); ?></div>
<?php } ?>
</div><!-- #site-info -->
<?php wp_nav_menu( array( 'container_class' => 'header-nav', 'theme_location' => 'header' ) ); ?>
<div id="social-networks">
<?php if(get_option('shaken_twitter')){ ?>
<a href="http://twitter.com/<?php echo get_option('shaken_twitter'); ?>" title="Tweets" class="twitter">Twitter</a>
<?php }
if(get_option('shaken_facebook')){ ?>
<a href="<?php echo get_option('shaken_facebook'); ?>" title="Facebook" class="facebook">Facebook</a>
<?php }
if(get_option('shaken_youtube')){ ?>
<a href="http://www.youtube.com/user/<?php echo get_option('shaken_youtube'); ?>" title="YouTube" class="youtube">YouTube</a>
<?php }
if(get_option('shaken_vimeo')){ ?>
<a href="http://www.vimeo.com/<?php echo get_option('shaken_vimeo'); ?>" title="Vimeo" class="vimeo">Vimeo</a>
<?php }
if(get_option('shaken_flickr')){ ?>
<a href="http://www.flickr.com/photos/<?php echo get_option('shaken_flickr'); ?>/" title="Flickr" class="flickr">Flickr</a>
<?php }
if(get_option('shaken_delicious')){ ?>
<a href="http://delicious.com/<?php echo get_option('shaken_delicious'); ?>" title="Bookmarks" class="delicious">Delicious</a>
<?php }
if(get_option('shaken_email')){ ?>
<a href="mailto:<?php echo get_option('shaken_email'); ?>" title="Email" class="email">Email</a>
<?php } ?>
<?php /* Widgetized sidebar */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('header') ) : ?><?php endif; ?>
<a href="<?php if(get_option('shaken_rss')){ echo get_option('shaken_rss'); } else { bloginfo('rss2_url'); }?>" title="Subscribe" class="rss">RSS</a>
</div><!-- #social-networks -->
<div class="clearfix"></div>
</div>
<strong>functions.php</strong>
<?php
$functions_path = TEMPLATEPATH . '/functions/';
$widgets_path = TEMPLATEPATH . '/functions/widgets/';
add_custom_background();
add_editor_style();
// -------------- Add support for gallery post thumbnails --------------
add_theme_support( 'post-thumbnails');
set_post_thumbnail_size( 310, 800);
add_image_size( 'sidebar', 75, 75, true);
add_image_size( 'col1', 135, 650);
add_image_size( 'col3', 485, 800);
add_image_size( 'col4', 660, 800);
// -------------- Add support for nav menus --------------
register_nav_menus( array(
'header' => __( 'Header Menu'),
) );
// ========================================================================================
// Default Functions
// ========================================================================================
// smart jquery inclusion
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false);
wp_enqueue_script('jquery');
}
// enable threaded comments
function enable_threaded_comments(){
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
wp_enqueue_script('comment-reply');
}
}
add_action('get_header', 'enable_threaded_comments');
// no more jumping for read more link
function no_more_jumping($post) {
return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Continue Reading'.'</a>';
}
add_filter('excerpt_more', 'no_more_jumping');
// -------------- Register Menus --------------
register_sidebar( array (
'name' => 'Page Sidebar',
'id' => 'page-sidebar',
'description' => __( 'The sidebar on basic pages'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array (
'name' => "Unique Sidebar",
'id' => 'unique-sidebar',
'description' => __( 'The sidebar on pages with the template of "Unique Sidebar" assigned to them.'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array (
'name' => "Blog Post Sidebar",
'id' => 'post-sidebar',
'description' => __( 'The sidebar on blog post pages'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array (
'name' => "header",
'id' => 'header',
'description' => __( 'The sidebar on blog post pages'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array (
'name' => 'Gallery Sidebar',
'id' => 'gallery-sidebar',
'description' => __( 'The sidebar on the gallery and archive pages'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// -------------- Custom Widgets --------------
//require_once ($widgets_path . 'sidebar-query.php');
require_once ($widgets_path . 'flickr.php');
require_once ($widgets_path . 'twitter.php');
require_once ($widgets_path . 'category-posts.php');
require_once ($widgets_path . 'testimonials.php');
require_once ($widgets_path . 'related-posts.php');
require_once ($widgets_path . 'popular-posts.php');
require_once ($widgets_path . 'share.php');
require_once ($widgets_path . 'ads.php');
// -------------- Theme Options Panel --------------
require_once ($functions_path . 'admin-options.php');
// -------------- Cusotm Post Fields --------------
require_once ($functions_path . 'admin-custom.php');
// -------------- Custom Excerpt Lengths --------------
require_once ($functions_path . 'custom-excerpts.php');
function shaken_head() {
echo '<link rel="stylesheet" href="'.get_bloginfo('template_url').'/functions/functions.css" type="text/css" media="all" />';
echo '<link rel="stylesheet" href="'.get_bloginfo('template_url').'/functions/scripts/colorpicker/style.css" type="text/css" media="all" />';
echo '<script src="'.get_bloginfo('template_url').'/functions/scripts/colorpicker/jquery.colorpicker.js" type="text/javascript"></script>';
echo '<script src="'.get_bloginfo('template_url').'/functions/scripts/colorpicker/jquery.eye.js" type="text/javascript"></script>';
}
add_action('admin_head','shaken_head');
// -------------- Custom Styles --------------
add_action( 'parse_request', 'shaken_custom_styles' );
function shaken_custom_styles($wp) {
if (
!empty( $_GET['shaken-custom-content'] )
&& $_GET['shaken-custom-content'] == 'css'
) {
header( 'Content-Type: text/css' );
require dirname( __FILE__ ) . '/custom-styles.php';
exit;
}
}
// -------------- Add featured images to RSS feed --------------
function feedContentFilter($content) {
$thumbId = get_post_thumbnail_id();
if($thumbId) {
$img = wp_get_attachment_image_src($thumbId, 'col3');
$image = '<img src="'. $img[0] .'" alt="" width="'. $img[1] .'" height="'. $img[2] .'" />';
echo $image;
}
return $content;
}
function feedFilter($query) {
if ($query->is_feed) {
add_filter('the_content', 'feedContentFilter');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');
// -------------- Custom Comment Structure --------------
if ( ! function_exists( 'shaken_comment' ) ) :
function shaken_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="author-avatar"><?php echo get_avatar( $comment, 70 ); ?></div>
<div class="comment-meta">
<span class="author-name"><?php printf( __( '%s', 'shaken' ), sprintf( '%s', get_comment_author_link() ) ); ?></span>
<span class="comment-date"><?php printf( __( '%1$s at %2$s', 'shaken' ), get_comment_date('M j, Y'), get_comment_time() ); ?><?php edit_comment_link( __( '(Edit)', 'shaken' ), ' ' );?></span>
</div><!-- .comment-meta -->
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'shaken' ); ?></em>
<br />
<?php endif; ?>
<?php comment_text(); ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</div><!-- #comment-ID -->
<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'shaken' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'shaken'), ' ' ); ?></p>
<?php
break;
endswitch;
} endif;
?>
Hope this helps.
juaribd comments:
Sorry, that would be functions.php