Skip to content

Instantly share code, notes, and snippets.

@goshdarnit
Created April 27, 2010 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goshdarnit/380181 to your computer and use it in GitHub Desktop.
Save goshdarnit/380181 to your computer and use it in GitHub Desktop.
<?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 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( 200, 200, true );
//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">
<div class="entry-content">
<?php
the_post_thumbnail( array(200,200) );
the_content(); ?>
</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 port
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200, 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>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">
<div class="entry-content">
<?php
the_post_thumbnail( array(200,200) );
the_content(); ?>
</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');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment