WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 15 2011

Add Custom CSS File Based on Page Type: Front Page, Home Page, Category Page, Archive Page, 404 Page, Author Page, and Page

So I found one question that I read that asked how to have a custom CSS file per page. Here's an easy way to add custom CSS files based on simple conditional logic in Genesis.

[php]
remove_action('genesis_meta', 'genesis_load_stylesheet'); //removes current stylesheet
add_action('genesis_meta','genesis_custom_css');
//get_bloginfo('stylesheet_url') is our normal style.css
function genesis_custom_css() {
if (is_category())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/cat_style.css" type="text/css" media="screen" />'."n";
if (is_home() || is_front_page())
echo '<link rel="stylesheet" href="'.get_bloginfo('stylesheet_url').'" type="text/css" media="screen" />'."n";
if (is_archive())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/arch_style.css" type="text/css" media="screen" />'."n";
if (is_author())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/auth_style.css" type="text/css" media="screen" />'."n";
if (is_page()) //also can take $pages=array(1,2,3); adding and elseif or else at the end.
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/page_style.css" type="text/css" media="screen" />'."n";
if (is_404())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/page_style.css" type="text/css" media="screen" />'."n";
}
[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 14 2011

Genesis Expose Category Template Matching Homepage

When I was checking out Expose Child Theme at StudioPress, I was slightly disappointed that when I clicked on a category that it didn't resemble the homepage in any way. Personally, I would love to see an option in Theme Settings that asked whether I wanted to have my category archive pages to reflect the homepage or a normal category archive page as they have now. While I have taken the home template and dubbed it into a category template, more things can easily be added. If you want to download the file: [download id="3"].

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 13 2011

How to Widgetize the Home Page of the Expose Genesis Child Theme

In order to widgetize the Expose Child Theme, you have to do three things.

1. Edit the CSS to make .portfolio-posts absolute. So find the following CSS.

[html]#content .portfolio-posts, {
background: #FFFFFF;
float: left;
width: 280px;
min-height: 280px;
margin: 0 10px 10px 10px;
padding: 9px 9px 9px 9px;
border: 1px solid #D5D5D5;
display: inline;
-moz-box-shadow: 0 0 3px #BBBBBB;
-webkit-box-shadow: 0 0 3px #BBBBBB;
overflow: hidden;
}

#content .portfolio-posts h2 {
font-size: 18px;
}

#content .portfolio-posts p {
line-height: 20px;
}[/html]

and delete #content.

2. Edit functions.php to include the widgeted area. Add the following code after // Register widget areas:
[php]genesis_register_sidebar(array(
'name'=>'Home 1',
'id' => 'home-1',
'description' => 'This is the first section of the homepage.',
'before_title'=>'<h3 class="widgettitle">','after_title'=>'</h3>'
));
genesis_register_sidebar(array(
'name'=>'Home 2',
'id' => 'home-2',
'description' => 'This is the first section of the homepage.',
'before_title'=>'<h3 class="widgettitle">','after_title'=>'</h3>'
));
genesis_register_sidebar(array(
'name'=>'Home 3',
'id' => 'home-3',
'description' => 'This is the first section of the homepage.',
'before_title'=>'<h3 class="widgettitle">','after_title'=>'</h3>'
));[/php]

3. Edit home.php to incorporate the widget. Then comment out the following:
[php]//require_once(PARENT_DIR . '/index.php');[/php]

And add the following just after that:
[php]get_header();
genesis_home(); ?>

<div id="content home-widgeted">
<div class="widgeted-home home-1">
<?php if (!dynamic_sidebar('Home 1')) : ?>
<div class="widget">
<h4><?php _e("Home", 'genesis'); ?></h4>
<p><?php _e("This is a widgeted area which is called Home.", 'genesis'); ?></p>
</div>
<?php endif; ?>
</div><!-- end .widgeted-home home-1-->
<div class="widgeted-home home-2">
<?php if (!dynamic_sidebar('Home 2')) : ?>
<div class="widget">
<h4><?php _e("Home", 'genesis'); ?></h4>
<p><?php _e("This is a widgeted area which is called Home.", 'genesis'); ?></p>
</div>
<?php endif; ?>
</div><!-- end .widgeted-home home-2-->
<div class="widgeted-home home-3">
<?php if (!dynamic_sidebar('Home 3')) : ?>
<div class="widget">
<h4><?php _e("Home", 'genesis'); ?></h4>
<p><?php _e("This is a widgeted area which is called Home.", 'genesis'); ?></p>
</div>
<?php endif; ?>
</div><!-- end .widgeted-home home-3-->
</div><!-- end #home-widgeted -->

<?php get_footer(); ?>[/php]

Now, Expose Home Page is widget ready to give more control on the front page. You may need to add some CSS to style even further.

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 12 2011

Prevent WordPress from Inserting Paragraph Tags Automatically to Validate Correctly

Ever gotten something like:Ā Line 61, Column 56: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag when you validate your code? This is because by default, WordPress automatically inserts paragraph tags all over the place when displaying ā€˜the_content’ creating validation issues (inserting implicit <p>). If you want to strip the automatically inserted paragraph tags from your content, simply insert this line in your template file above ā€˜the_content’ tag:

[php]<?php remove_filter (ā€˜the_content’, ā€˜wpautop’); ?>[/php]

Another method, if you prefer not to use this one is to insert </p> before <div> or shortcodes like [nggallery id=x]. This will help your pages validate correctly.

Written by Travis Smith · Categorized: Tutorials

Mar 11 2011

Create a Widgetized Ad Area for Genesis

To add ads at the bottom of the posts, you can add ad content space. A good way would be to widgetize it and use Widget Logic to control what ad appears on what page, etc.

So, add this to your functions.php file.
[php]genesis_register_sidebar(array(
'name'=>'Ad Content',
'description' => 'Place widgets here to fill the ad content area that appears after posts.',
));
function add_ad_content() { ?>
<div class="ad_content">
<?php if (!dynamic_sidebar('Ad Content')) : ?>
<h3><?php _e("Ad Content Area", 'genesis'); ?></h3>
<p><?php _e("This is a widgeted area designed to hold ad content.", 'genesis'); ?></p>
<?php endif; ?>
</div><!-- end .homepage_content -->
<?php }
add_action ('genesis_after_post_content','add_ad_content');[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

  • « Previous Page
  • 1
  • …
  • 50
  • 51
  • 52
  • 53
  • 54
  • …
  • 61
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 ļæ½ WP Smith on Genesis on Genesis Framework ļæ½ WordPress ļæ½ Log in