Created
May 11, 2010 16:16
-
-
Save goshdarnit/397493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// Custom Child Theme Functions | |
// | |
// I've included a "commented out" sample function below that'll add a home link to your menu | |
// More ideas can be found on "A Guide To Customizing The Thematic Theme Framework" | |
// http://themeshaper.com/thematic-for-wordpress/guide-customizing-thematic-theme-framework/ | |
// Adds a home link to your menu | |
// http://codex.wordpress.org/Template_Tags/wp_page_menu | |
//function childtheme_menu_args($args) { | |
// $args = array( | |
// 'show_home' => 'Home', | |
// 'sort_column' => 'menu_order', | |
// 'menu_class' => 'menu', | |
// 'echo' => true | |
// ); | |
// return $args; | |
//} | |
//add_filter('wp_page_menu_args','childtheme_menu_args'); | |
// ---------------------------------------------------------------- First we make our function | |
function childtheme_welcome_blurb() { | |
if (is_home() & !is_paged()) { ?> | |
<div id="extra-info" class="span-26"> | |
<p>I love designing beautiful websites and building brands.</p> | |
<p>I am always interested in any opportunities. Say hello <a class="big" href="#">HERE</a></p> | |
</div> | |
<?php } | |
} | |
//add_action('thematic_belowheader','childtheme_welcome_blurb'); | |
add_filter('thematic_indexloop','childtheme_welcome_blurb'); | |
// ---------------------------------------------------------------- loops | |
/* Get rid of the original loop first (otherwise we'll have two of them): */ | |
function remove_index_loop() { | |
remove_action('thematic_indexloop', 'thematic_index_loop'); | |
} | |
add_action('init', 'remove_index_loop'); | |
global $post; // if outside the loop | |
function remove_thematic_blogdescription() { | |
if (!is_home()) { | |
remove_action('thematic_header','thematic_blogdescription',5); | |
} | |
} | |
add_action('thematic_before','remove_thematic_blogdescription'); | |
function remove_sidebar() { | |
if (!is_home()) { | |
return FALSE; | |
} else { | |
return TRUE; | |
} | |
} | |
add_filter('thematic_sidebar', 'remove_sidebar'); | |
/* Make sure thematic_indexloop changes the loop for the index page only or everywhere in WP: */ | |
//add_action('thematic_belowcontainer', 'gallery_category'); | |
add_theme_support( 'post-thumbnails' ); | |
set_post_thumbnail_size( 250, 200, true ); // Normal post thumbnails | |
add_image_size( 'single-post-thumbnail', 400, 9999 ); // Permalink thumbnail size | |
//Create a query to use with a loop. Big thanks to Allan Cole - www.allancole.com - for sharing his code! | |
// First, grab any global settings you may need for your loop. | |
//Creating a div to hold all gallery posts | |
function gallery_category(){ | |
if (is_home() & !is_paged()) {?> | |
<div id="gallerycontent" class="prepend-1"> | |
<div id="galleryheader"> | |
<h1>FEATURED PORTFOLIO</h1> | |
</div> | |
<div id='gallery_category'> | |
<?php | |
global $paged, $more; | |
$more = 0; | |
// Second, create a new temporary Variable for your query. | |
// $creative_query is the Variable used in this example query. | |
// If you run any new Queries, change the variable to something else more specific ie: $feature_wp_query. | |
$temp = $portfolio_query; | |
// Next, set your new Variable to NULL so it's empty. | |
$portfolio_query = null; | |
// Then, turn your variable int the WP_Query() function. | |
$portfolio_query = new WP_Query(); | |
// Set you're query parameters. Need more Parameters?: http://codex.wordpress.org/Template_Tags/query_posts | |
$portfolio_query->query(array( | |
// This will create a loop that shows 2 posts from the creative category. | |
'category_name' => 'portfolio', | |
'posts_per_page' => 4, | |
)); ?> | |
<?php | |
$count = 1; | |
// While posts exists in the Query, display them. | |
while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?> | |
<?php // Start the looped content here. ?> | |
<div class="post"> | |
<!-- Display the Title as a link to the Post's permalink. --> | |
<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> | |
<div class="entry-content"> | |
<?php | |
the_post_thumbnail( array(250,200) ); | |
?> | |
</div> | |
</div> <!-- closes the first div box --> | |
<!--This is how to end a loop --> | |
<?php | |
/* In the case you're rendering the very last post, do nothing: */ | |
if ($count == 4){ | |
// Do nothing, thematic will add a '</div>' to close the last post | |
/* Is this the last post in the column? | |
That means if the loop number divides by 2 (or whatever post per column number we choose) */ | |
} elseif ($count%2 == 0){ | |
/* if this is the bottom post, close the div and start a new div: */ | |
echo '</div> | |
<div id="column2" class="prepend-8">'; | |
} else { | |
/* Do nothing, just move on, nothing to see here... */ | |
} | |
/* We're about to finish the loop, let's add 1 to the count: */ | |
$count = $count + 1; | |
endwhile; /* loop done, go back up */ | |
/* All the posts are done, close the last column: */ | |
echo '</div>'; | |
?> | |
</div> | |
<?php | |
// End the Query and set it back to temporary so that it doesn't interfere with other queries. | |
$portfolio_query = null; | |
$portfolio_query = $temp; | |
} | |
} | |
//Add the function to the Action Hook. | |
add_action('thematic_belowcontainer','gallery_category'); | |
// ---------------------------------------------------------------- loops for the portfolio | |
add_theme_support( 'post-thumbnails' ); | |
set_post_thumbnail_size( 250, 200, true ); | |
add_image_size( 'single-post-thumbnail', 400, 9999 ); | |
function gallerypg_category(){ | |
if (is_page('portfolio')) {?> | |
<div id="gallerycontentpg" class="prepend-1"> | |
<div id="galleryheaderpg"> | |
<h1>CHECK OUT MY PORTFOLIO</h1> | |
</div> | |
<div id='gallery_categorypg'> | |
<?php | |
global $paged, $more; | |
$more = 0; | |
// Second, create a new temporary Variable for your query. | |
// $creative_query is the Variable used in this example query. | |
// If you run any new Queries, change the variable to something else more specific ie: $feature_wp_query. | |
$temp = $portfolio_query; | |
// Next, set your new Variable to NULL so it's empty. | |
$portfolio_query = null; | |
// Then, turn your variable int the WP_Query() function. | |
$portfolio_query = new WP_Query(); | |
// Set you're query parameters. Need more Parameters?: http://codex.wordpress.org/Template_Tags/query_posts | |
$portfolio_query->query(array( | |
// This will create a loop that shows 2 posts from the creative category. | |
'category_name' => 'portfolio', | |
'showposts' => '9', | |
)); ?> | |
<?php | |
$count = 1; | |
/***** Add a counter that controls the column ids. */ | |
$colCount = 1; | |
// While posts exists in the Query, display them. | |
while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?> | |
<?php // Start the looped content here. ?> | |
<div class="post"> | |
<!-- Display the Title as a link to the Post's permalink. --> | |
<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> | |
<div class="entry-content"> | |
<?php | |
the_post_thumbnail( array(250,200) ); | |
?> | |
</div> | |
</div> <!-- closes the first div box --> | |
<!--This is how to end a loop --> | |
<?php | |
/* In the case you're rendering the very last post, do nothing: */ | |
if ($count == 9){ | |
// Do nothing, thematic will add a '</div>' to close the last post | |
/* Is this the last post in the column? | |
That means if the loop number divides by 2 (or whatever post per column number we choose) */ | |
/*If second colum*/ | |
} elseif ($count%6 == 0){ | |
/*If third column*/ | |
/* if this is the bottom post, close the div and start a new div: */ | |
echo '</div> | |
<div id="column3pg" class="prepend-16">'; | |
} elseif ($count%3 == 0){ | |
/*If third column*/ | |
/* if this is the bottom post, close the div and start a new div: */ | |
echo '</div> | |
<div id="column2pg" class="prepend-8">'; | |
?> | |
<?php | |
} else { | |
} | |
/* We're about to finish the loop, let's add 1 to the count: */ | |
$count = $count + 1; | |
endwhile; /* loop done, go back up */ | |
/* All the posts are done, close the last column: */ | |
echo '</div>'; | |
echo '</div>'; | |
// End the Query and set it back to temporary so that it doesn't interfere with other queries. | |
$portfolio_query = null; | |
$portfolio_query = $temp; | |
} | |
} | |
//Add the function to the Action Hook. | |
add_action('thematic_belowcontainer','gallerypg_category'); | |
// ---------------------------------------------------------------- about page | |
function about_header() { | |
if (is_page() & !is_page('portfolio') & !is_page('contact')) { ?> | |
<div id="about-info" class="prepend-1"> | |
<h1>I LOVE TAKING ON EXCITING NEW PROJECTS AND MEETING COOL PEOPLE</h1> | |
</div> | |
<?php } | |
} | |
//add_action('thematic_belowheader','childtheme_welcome_blurb'); | |
add_action('thematic_abovecontainer','about_header'); | |
function contact_header() { | |
if (is_page('contact') & !is_page('portfolio') & !is_page('about')) { ?> | |
<div id="contact-info" class="prepend-1 span-22"> | |
<h1>WANT TO GET IN TOUCH? I'D LOVE TO HEAR ABOUT WHAT YOU HAVE TO SAY!</h1> | |
</div> | |
<?php } | |
} | |
//add_action('thematic_belowheader','childtheme_welcome_blurb'); | |
add_action('thematic_abovecontainer','contact_header'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment