Skip to content

Instantly share code, notes, and snippets.

@brycejacobson
brycejacobson / functions.php
Created September 17, 2013 18:51
WordPress ie8 Conditional CSS
<?php
//* IE8 condital stylesheet
add_action( 'wp_enqueue_scripts', 'print_my_styles' );
function print_my_styles() {
global $wp_styles;
wp_enqueue_style( 'ie8', get_stylesheet_directory_uri() . '/ie8.css' );
$wp_styles->add_data( 'ie8', 'conditional', 'lt IE 9' );
}
@brycejacobson
brycejacobson / page.php
Created September 25, 2013 15:53
Genesis Custom Loop With Content Limit
<?php
add_action( 'genesis_loop', 'be_custom_loop' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
function be_custom_loop() {
global $post;
// arguments, adjust as needed
$args = array(
@brycejacobson
brycejacobson / page.php
Created September 30, 2013 20:48
Get date from a WordPress Custom Field and alter its format.
<?php
//* Get date from a WordPress Custom Field and alter its format.
$display_date = date('F d, Y', strtotime(get_post_meta($post->ID, "event_start_date", true)));
echo $display_date;
@brycejacobson
brycejacobson / functions.php
Last active December 26, 2015 08:29
WordPress change the Login Logo
<?php
// Change the default WordPress login logo
function my_login_logo() { ?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(<?php echo get_bloginfo( 'template_directory' ); ?>/images/site-login-logo.png);
padding-bottom: 30px;
}
</style>
@brycejacobson
brycejacobson / content.php
Created November 20, 2013 20:07
Combine next or number for WordPress wp_link_pages <!--nextpage--> function.
<?php wp_link_pages(array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'next_or_number' => 'next_and_number', 'separator' => '', 'nextpagelink' => __( '&raquo;' ), 'previouspagelink' => __( '&laquo;' ), 'pagelink' => '%')); ?>
@brycejacobson
brycejacobson / page_template.php
Created December 4, 2013 21:17
Get custom field date in WP_Query and show the post if the date is in the future. Using Advance Custom Fields.
<?php
$today = date('Ymd', strtotime('-1 day'));
// WP_Query arguments
$args = array (
'post_type' => 'construction_bids',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'bid_deadline',
'value' => $today,
@brycejacobson
brycejacobson / index.html
Created December 13, 2013 19:19
Smooth scroll to an id and trigger Cycle2 slide change.
<a href="#slide-rio-medley" data-target="slider"></a>
<div id="slider"></div>
@brycejacobson
brycejacobson / functions.php
Created December 26, 2013 19:59
Add featured image to Genesis single post with full control of options. Also a cleaner version with no image link.
<?php
// Add featured image to single posts.
add_action ( 'genesis_entry_content', 'aafcm_show_featured_image_single', 1 );
function aafcm_show_featured_image_single() {
global $post;
if ( is_page() )
return; // Make pages act normal
//setup thumbnail image args to be used with genesis_get_image();
@brycejacobson
brycejacobson / functions.php
Created February 11, 2014 17:14
Programmatically add menu Item in WordPress
<?php
add_filter( 'wp_nav_menu_items', 'add_logout_link', 10, 2);
/**
* Add a login link to the members navigation
*/
function add_logout_link( $items, $args )
{
if($args->theme_location == 'site_navigation')
@brycejacobson
brycejacobson / wp-config.php
Created February 12, 2014 15:25
Enable background updates in WordPress on site where it fails.
<?php
/**
* Enabling automatic updates.
*/
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'localhost');