WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

May 18 2011

How to Remove or Move the Genesis Footer below the #wrap

It is easy to remove.move the footer, simply add this to your functions.php.

To remove the footer, use:
[php]remove_action( 'genesis_footer', 'genesis_do_footer' );[/php]

To move the footer below the body #wrap, use:
[php]remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'wp_footer', 'genesis_do_footer' );[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

May 16 2011

A Genesis iFrame Page Template

***UPDATED: 5/16***
Recently, I needed an iFrame page template so that I could create pages that appear on multiple external websites, especially Facebook pages. So in order to do this, I had to remove the header, navigation, footer, breadcrumbs, and post title. For styling, I added an iframe custom body class. Here is a Sample iFrame Page.

So here is the code from the page:
[php]
<?php
/*
*Template Name: iframe
*/

remove_action('genesis_header', 'genesis_header_markup_open', 5);
remove_action('genesis_header', 'genesis_do_header');
remove_action('genesis_after_header', 'genesis_do_nav');
remove_action('genesis_after_header', 'genesis_do_subnav');
remove_action('genesis_footer', 'genesis_do_footer');
remove_action('genesis_before_footer', 'metric_include_footer_widgets');
remove_action('wp_head', 'genesis_header_scripts');
remove_action('genesis_before_loop', 'genesis_do_breadcrumbs');
remove_action('genesis_post_title', 'genesis_do_post_title');
add_filter('body_class','my_body_classes');
function my_body_classes($classes) {
$classes[] = "iframe";
return $classes;
}

genesis();
?>
[/php]

For example, it can be styled by adding something like the following:
[html]body.iframe {
background: none repeat scroll 0 0 #FFFFFF;
}[/html]

You could also remove the sidebar or you could just force the layout to be full-width:
[php]add_filter('genesis_pre_get_option_site_layout', 'wps_iframe_layout');
function wps_iframe_layout($opt) {
$opt = 'full-width-content';
return $opt;
} [/php]

The possibilities of this are endless! I would love to know what you do with this!

Written by Travis Smith · Categorized: Genesis, Tutorials

May 13 2011

How to Add Google Adsense After the First (or Second) Paragraph of a Post in Genesis

This question was raised in the StudioPress forums: How to Add Google Adsense After the First (or Second) Paragraph of a Post in Genesis? So here's how I did it initially:

[php]<?php
add_filter( 'the_content', 'my_add_after_first_p', 20 );
function my_add_after_first_p( $content ) {
$ad = '</p><p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxxxx";
/* 468x60, created 10/4/09 */
google_ad_slot = "xxxxxxxxxx";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>';
$content = preg_replace( "/</p>/", $ad, $content, 1 );
return $content;
}
?> [/php]

However, I then came across another method (on @wpbeginner who grab it from somewhere else), which I like better, after the individual wanted it after the 2nd paragraph. So copy the following code and place it in its own php file called adsense.php (or download it here: [download id="9"]).

[php]<?php
$paragraphAfter= 1; //display after the first paragraph, change to 2 for 2nd paragraph
$ad = '</p><p style="text-align: center;">
<script type="text/javascript"><!--google_ad_client = "pub-xxxxxxxxxxxxxxxxxx"; /* 468x60, created 10/4/09 */
google_ad_slot = "xxxxxxxxxx";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></p>';
$content = apply_filters('the_content', get_the_content());
$content = explode("</p>", $content);
for ($i = 0; $i <count($content); $i++ ) {
if ($i == $paragraphAfter)
echo $ad;

echo $content[$i] . "</p>";
}
?>
[/php]

Then in functions.php add the following:
[php]
add_action('genesis_before_post_content', 'include_adsense');
function include_adsense() {
if ( is_single() )
require_once(CHILD_DIR . '/adsense.php');
}
[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

May 11 2011

How to Add a Login/Logout Link to Your WordPress Genesis Custom Menu Based on Menu Location

So one of the things I was looking into was how to add a login/logout link to th This e Navigation. However, when I first did it, I did it to all of them; however, I finally figured out how to create this link, as seen in the footer, in the menu based on the menu. This tutorial targets Genesis users but non-Genesis users can use the same code with the deletion of the last line.

All Genesis themes have Primary and Secondary menus registered in the Genesis engine.
{DO NOT ADD THIS CODE ANYWHERE: DEMO ONLY}
[php]<?php
register_nav_menus( array(
'primary' => __('Primary Navigation Menu', 'genesis'),
'secondary' => __('Secondary Navigation Menu', 'genesis')
) );
?>[/php]

As you can see the two names are primary and secondary in lower case. One other Genesis child theme, News, registers a menu called topnav.

You will need to add the following to your functions.php file based on where you want the link to occur.

[php highlight="4,5,6,7,8,9,10,11"]
<?php
function wps_add_loginlogout_link($items, $args)
{
//defaults; change this as you see fit
$defaults = array(
'loginlout_position' => 999, //enter 0 for front, 999 for end
'menu_id' => 'menu-item', //custom CSS
'menu_class' => 'menu-item menu-item-type-custom menu-item-object-custom', //custom CSS
'menu_location' =>'primary', //enter primary, secondary, or topnav for News
'loginredirect' => false //enter true for redirect to wp-admin dashboard
);

//do nothing if not proper menu location
if( $args->theme_location != $defaults['menu_location'] )
return $items;

//set redirect URL
if( $defaults['loginredirect'] )
$wpurl = 'wp-admin/index.php';
else
$wpurl = 'index.php';

// split the menu items into an array using the ending <li> tag
if ( $defaults['loginlout_position'] != 0 && $defaults['loginlout_position'] != 1 && $defaults['loginlout_position'] != 999 ) {
$items = explode('</li>',$items);
}

if(is_user_logged_in())
{
$newitem = '<li id="'.$defaults['menu_id'].'" class="'.$defaults['menu_class'].'"><a title="Logout" href="'. wp_logout_url($wpurl) .'">Logout</a></li>';
if ( $defaults['loginlout_position'] == 0 || $defaults['loginlout_position'] == 1 )
$newitems = $newitem.$items;
elseif ( $defaults['loginlout_position'] == 999 )
$newitems = $items.$newitem;
else
$newitem = '<li id="'.$defaults['menu_id'].'" class="'.$defaults['menu_class'].'">' . $args->before . '<a title="Logout" href="'. wp_logout_url('index.php') .'">' . $args->link_before . 'Logout' . $args->link_after . '</a>' . $args->after; // no </li> needed this is added later
}
else
{
$newitem = '<li id="'.$defaults['menu_id'].'" class="'.$defaults['menu_class'].'"><a title="Login" href="'. wp_login_url($wpurl) .'">Login</a></li>';
if ( $defaults['loginlout_position'] == 0 || $defaults['loginlout_position'] == 1 )
$newitems = $newitem.$items;
elseif ( $defaults['loginlout_position'] == 999 )
$newitems = $items.$newitem;
else
$newitem = '<li id="'.$defaults['menu_id'].'" class="'.$defaults['menu_class'].'">' . $args->before . '<a title="Login" href="'. wp_login_url('index.php') .'">' . $args->link_before . 'Login' . $args->link_after . '</a>' . $args->after; // no </li> needed this is added later
}

if ( $defaults['loginlout_position'] != 0 && $defaults['loginlout_position'] != 1 && $defaults['loginlout_position'] != 999 ) {
$newitems = array();

// loop through the menu items, and add the new link at the right position
foreach($items as $index => $item)
{
// array indexes are always one less than the position (1st item is index 0)
if($index == $defaults['loginlout_position']-1)
{
$newitems[] = $newitem;
}
$newitems[] = $item;
}

// finally put all the menu items back together into a string using the ending <li> tag and return
$newitems = implode('</li>',$newitems);
}

return $newitems;
}
add_filter('wp_nav_menu_items', 'wps_add_loginlogout_link', 10, 2);
add_filter('genesis_nav_items', 'wps_add_loginlogout_link', 10, 2); //non-Genesis users delete this line.
?>
[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

May 10 2011

How to Change the Default Genesis Favicon and Upload My Own

Genesis has a function called genesis_load_favicon that searches the Child theme's folder for an ico, gif, png, or jpg favicon file (e.g., favicon.ico, favicon.gif, favicon.png, favicon.jpg). It also has a filter for the URL and a filter to short-circuit the entire function.

Once you’ve made your new custom favicon.ico (Use photoshop to make a small png or use this plugin/add-on), upload it to your child theme’s images directory.

Or, if you have a network of sites and want to pull a favicon from somewhere else, you can use this function in your functions.php file.

After you have done one of these two things, you may still see the Genesis favicon and think your favicon has not been changed. However, trust me, it has been changed and your cache is causing the issue. If you really, really want to see it immediately, then clear the cache in all your browsers, close all web applications, restart computer, and be patient. Or, just call/contact someone else to check for you.

Written by Travis Smith · Categorized: Genesis, Tutorials

  • « Previous Page
  • 1
  • …
  • 4
  • 5
  • 6
  • 7
  • 8
  • …
  • 18
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in