Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / gist:367037e18fbee47f5ccf
Created July 30, 2014 23:12
Featured Image with captions
if ( ! function_exists( 'mytheme_entry_image' ) ) :
/**
* Display an optional entry thumbnail.
*/
function mytheme_entry_image() {
if ( ! has_post_thumbnail() ) {
return;
}
$featured_image = get_post_thumbnail_id();
$attachment_page = esc_url( get_attachment_link( $featured_image ) );
$latest_posts = new WP_Query( array(
'posts_per_page'=>3,
'ignore_sticky_posts' => true
)
);
if ( $latest_posts->have_posts()) : ?>
<ul class="latest-posts clear">
<?php while($latest_posts->have_posts()) : $latest_posts->the_post(); ?>
<li id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
@designbuildtest
designbuildtest / gist:10c68c382040d39d53bc
Last active August 29, 2015 14:03
Activate WebDevStudio's cmb class
<?php
/**
* Initialize Custom Metabox class.
* https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress
* https://github.com/mustardBees/cmb_field_map
*/
function sendtheme_initialize_metaboxes() {
if ( !class_exists( 'cmb_Meta_Box' ) ) {
require_once get_template_directory() . '/metaboxes-1.2.0/init.php';
<?php
// Add social media text inputs.
$social_media_array = array(
__( 'Facebook', 'twentyfourteen' ) => 'facebook',
__( 'Flickr', 'twentyfourteen' ) => 'flickr',
__( 'Google+', 'twentyfourteen' ) => 'googleplus',
__( 'Instagram', 'twentyfourteen' ) => 'instagram',
__( 'LinkedIn', 'twentyfourteen' ) => 'linkedin',
__( 'Pinterest', 'twentyfourteen' ) => 'pinterest',
__( 'Skype', 'twentyfourteen' ) => 'skype',
@designbuildtest
designbuildtest / gist:4d0907b06075cf7c7399
Created June 19, 2014 02:45
InfoWindow open on page load
var infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: '<?php echo get_the_title(); ?>'
});
<?php // Map page
if ( get_theme_mod( 'map_page' ) ) {
$map_page_id = get_theme_mod( 'map_page' ); ?>
<div class="location-map">
<a href="<?php echo esc_url( get_permalink( $map_page_id ) ); ?>" title="<?php echo esc_attr( get_the_title( $map_page_id ) ); ?>">
<?php echo esc_attr( get_the_title( $map_page_id ) ); ?>
</a>
</div><?php
} ?>
@designbuildtest
designbuildtest / gist:e6dfb85a7c0ee897ebce
Last active August 29, 2015 14:02
Customizer dropdown pages
<?php
$wp_customize->add_setting( 'select_page', array(
'default' => '',
) );
$wp_customize->add_control( 'map_page_control', array(
'label' => __( 'Select page', 'twentyfourteen' ),
'section' => 'theme_options',
'settings' => 'select_page',
<?php
// Slider autoplay toggle.
$wp_customize->add_setting( 'slider_autoplay', array(
'default' => 'disabled',
'sanitize_callback' => 'twentyfourteen_sanitize_slider_autoplay',
) );
$wp_customize->add_control( 'slider_autoplay', array(
'label' => __( 'Slider Autoplay', 'twentyfourteen' ),
'section' => 'featured_content',
@designbuildtest
designbuildtest / gist:132b5167297c628f9eb8
Last active August 29, 2015 14:02
Google Map integration
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["map"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
@designbuildtest
designbuildtest / gist:603577e0047365b4368f
Created May 26, 2014 23:22
Add a home link to wp_page_menu() by default
<?php
/**
* Add a home link to wp_page_menu() by default
*/
function twentyfourteen_page_menu_args( $args ) {
$show_on_front = get_option('show_on_front');
if ( $show_on_front == 'posts' ) {
$args['show_home'] = true;
}
return $args;