Skip to content

Instantly share code, notes, and snippets.

<style type="text/css">
.acf-map {
width: 100%;
height: 400px;
border: #ccc solid 1px;
margin: 20px 0;
}
/* fixes potential theme css conflict */
@leanda
leanda / user_email.php
Created July 14, 2016 13:43
ACF Save action hook to grab that email from member profile and update the user_email
/**
* ACF
*
* Save action hook to grab that email from member profile and update the user_email
*/
function my_acf_save_post( $post_id ) {
// bail early if no ACF data
if( empty($_POST['acf']) ) {
return;
}
@leanda
leanda / exclude.php
Created December 9, 2015 12:18
Excludes chosen category from home (functions.php)
/**
* Excludes chosen project category from home
*/
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-198');
}
return $query;
}
add_filter('pre_get_posts', 'excludeCat');
@leanda
leanda / acf_map_address.php
Created October 2, 2015 10:58
Explode address information ACF Google Map
<?php
$location = get_field('your_location');
if( !empty($location) ):
?>
<?php $location = explode( "," , $location['address']);
echo $location[0].', '; //street number
echo $location[1].','.$location[2]; //city, state + zip
// print_r($location);
@leanda
leanda / menu_title.php
Last active September 26, 2015 17:02
Get WordPress menu title
<?php echo get_menu_name( 'primary' ) ?>
/**
* Function to get the menu title
*/
function get_menu_name( $theme_location ) {
if( ! $theme_location ) return false;
@leanda
leanda / acf_lat_lng.php
Created September 24, 2015 10:37
Display the longitude and latitude corodinates using ACF and Google Map field.
<?php
$location = get_field('your_location');
if( !empty($location) ):
?>
<?php echo $location['lat']; ?>
<?php echo $location['lng']; ?>
<?php endif; ?>
@leanda
leanda / gist:8bb4c27a338a871a9006
Created December 7, 2014 14:35
Royal Slider Extra Slider code
// Add this to your theme functions.php
// new_rs_after_js_init_code action is available since v3.1.7.
function add_additional_rs_code() {
?>
// put JS code here
<!-- $('.rsGCaption').appendTo('.some-new-container')
-->
<?php
}
@leanda
leanda / _mixins.scss
Created July 14, 2014 13:40
WordPress Google Fonts
/**
* Create Mixins
*/
@mixin font-light {
font-family: 'Open Sans', "Helvetica Neue", Arial, sans-serif;
font-weight: 300;
font-style: normal;
}
@leanda
leanda / flexslider-wordpress-gallery.php
Created February 20, 2014 16:38
Flexslider wordpress gallery
@leanda
leanda / odd-even.php
Last active December 21, 2015 19:39
Add odd even class to posts
<div class="post <?php echo $i % 2 == 0 ? "even" : "odd" ?>">