Skip to content

Instantly share code, notes, and snippets.

View schalkburger's full-sized avatar
💪
eat sleep code repeat

Schalk Burger schalkburger

💪
eat sleep code repeat
View GitHub Profile
@schalkburger
schalkburger / wordpress-custom-login-logo.php
Last active August 29, 2015 14:15
Wordpress custom login logo
<?php
function custom_login_logo() {
echo '<style type="text/css">
h1 a {background-image: url('.get_bloginfo('template_directory').'/img/login_logo.png) !important; }
</style>';
}
add_action('login_head', 'custom_login_logo');
?>
@schalkburger
schalkburger / wordpress-list-page-children.php
Last active August 29, 2015 14:15
Wordpress list page children content
<?php
$args = array(
'post_type' => 'page',
'numberposts' => 99,
'post_status' => 'publish',
'order' => 'ASC',
'post_parent' => 1, // Any post parent
);
$attachments = get_posts($args);
if ($attachments) {
@schalkburger
schalkburger / wordpress-post-thumbs.php
Created February 17, 2015 09:30
Wordpress post thumbnails featured image reference
<?php add_theme_support( 'post-thumbnails' ); // Add theme post thumbnails support ?>
<?php the_post_thumbnail(); // Display post thumbnail ?>
<?php set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, crop mode // Set post thumbnail to 50 x 50 and does a hard crop ?>
<?php add_image_size( 'custom-thumb', 300, 9999 ); //300 pixels wide (and unlimited height) // Set post thumbnail to 300 x any height, no cropping ?>
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'custom-thumb' ); } else { ?> <img src="<?php bloginfo('template_directory');?>/img/thumb-default.png" alt=""/> <?php } ?>
@schalkburger
schalkburger / wordpress-short-url.php
Created February 17, 2015 09:34
Wordpress quick short URL
<?php if (function_exists('get_shortlink')) { // WP 3+ ?>
<div class="short-url">Short <abbr title="Uniform Resource Locator">URL</abbr>: <input onClick="this.focus(); this.select();" value="<?php echo get_shortlink(get_the_ID()); ?>" size="30" type="text" /></div>
<?php } ?>
@schalkburger
schalkburger / wordpress-remove-default-gallery-style.php
Created February 17, 2015 09:36
Wordpress remove default gallery style
@schalkburger
schalkburger / wordpress-list-posts.php
Created February 17, 2015 09:38
Wordpress list posts
<?php
if (is_page()) {
$cat=get_cat_ID($post->post_title); // Use page title to get a category ID
$posts = get_posts ("cat=$cat&showposts=3"); // Show 3 posts
if ($posts) {
foreach ($posts as $post):
setup_postdata($post); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
<?php endforeach;
@schalkburger
schalkburger / wordpress-search-unlimited-results.php
Created February 17, 2015 09:39
Wordpress search unlimited results
<?php // if (have_posts()) : ?>
<?php // while (have_posts()) : the_post(); ?>
<?php $posts=query_posts($query_string . '&posts_per_page=-1'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
@schalkburger
schalkburger / wordpress-change-email.php
Created February 17, 2015 09:43
Wordpress change from email details
<?php
add_filter( 'wp_mail_from', 'my_mail_from' );
function my_mail_from( $email )
{
return 'username@example.com';
}
add_filter( 'wp_mail_from_name', 'my_mail_from_name' );
function my_mail_from_name( $name )
{
return 'John Doe';
@schalkburger
schalkburger / css-sticky-footer.html
Created February 17, 2015 09:45
CSS sticky footer
@schalkburger
schalkburger / remove-wordpress-emoji.php
Created May 15, 2015 09:14
Remove Wordpress emoji
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );