Skip to content

Instantly share code, notes, and snippets.

@laras126
laras126 / gist:1095603
Created July 20, 2011 18:41
childtheme override
<?php
if (function_exists('childtheme_override_page_title')) {
function thematic_page_title() {
childtheme_override_page_title();
}
} else {
function thematic_page_title() {
/* code for the page title */
}
@laras126
laras126 / gist:1210003
Created September 11, 2011 19:31
wpfolio two thumbnails
<?php
// Add support for post thumbnails of 250px square
// Add custom image size for wpf thumbnails
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 270, 270, true );
add_image_size('wpf-thumb', 270, 270, true);
}
<?php
if ( function_exists( 'add_theme_support' ) ) {
// Add support for post thumbnails
add_theme_support( 'post-thumbnails' );
// Change thumbnail size to 270 x 270 with cropping
set_post_thumbnail_size( 270, 270, true );
// Create a custom image size of 270 x 270 with cropping
add_image_size('wpf-thumb', 270, 270, true);
}
@laras126
laras126 / gist:1210226
Created September 11, 2011 22:41
get attachments
<?php
// Get post attachments
function wpf_get_attachments() {
global $post;
return get_posts(
array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image')
);
@laras126
laras126 / gist:1224034
Created September 17, 2011 15:19
Get and display first attachment
<?php
// Get the URL of the first attachment image and turn it into the 'auto thumb'. If no attachments, display default-thumb.png
function wpf_get_first_thumb_url() {
// Add these classes to the attachment so that the 'auto thumb' style matches the style of featured image's
$attr = array(
'class' => "attachment-post-thumbnail wp-post-image");
$imgs = wpf_get_attachments();
@laras126
laras126 / functions.php
Created September 20, 2011 15:39
AJAX Calendar page template and functions
<?php
////////////////////////
// CALENDAR FUNCTIONS //
////////////////////////
/*
Function to Draw the calendar and it's controls.
@laras126
laras126 / gist:1240734
Created September 25, 2011 15:44
Make thumb a permalink
<?php
// Make featured image thumbnail a permalink
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
function my_post_image_html( $html, $post_id, $post_image_id ) {
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
return $html;
}
@laras126
laras126 / gist:1240748
Created September 25, 2011 15:54
echo thumbs
<?php
while (have_posts()) : the_post();
?>
<span class="thumb-list">
<div id="post-<?php the_ID();
echo '"> ';
if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) {
the_post_thumbnail();
} else { ?>
<a href="<?php the_permalink();?>"><?php wpf_get_first_thumb_url(); ?></a>
@laras126
laras126 / gist:1240755
Created September 25, 2011 15:59
filter gallery shortcode
<?php
// Filter the gallery shortcode defaults
// http://wordpress.stackexchange.com/questions/4343/how-to-customise-the-output-of-the-wp-image-gallery-shortcode-from-a-plugin
add_filter( 'post_gallery', 'my_post_gallery', 10, 2 );
function my_post_gallery( $output, $attr) {
global $post, $wp_locale;
static $instance = 0;
$instance++;
@laras126
laras126 / gist:1240759
Created September 25, 2011 16:02
Thumbnails css
/* Thumbnails */
span.thumb-list {
float:left;
padding-left:11px;
margin:auto;
}
h4.thumb-title,h4.thumb-title a,h4.thumb-title a:hover {
font-size:.8em;