Skip to content

Instantly share code, notes, and snippets.

View nmyers's full-sized avatar

Nicolas nmyers

View GitHub Profile
@nmyers
nmyers / add-open-graph.php
Last active June 23, 2016 11:03
Facebook open graph and Twitter card add in functions.php
function add_opengraph_markup() {
if (is_single()) {
global $post;
if(get_the_post_thumbnail($post->ID, 'thumbnail')) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_object = get_post($thumbnail_id);
$image = $thumbnail_object->guid;
} else {
// set default image
$image = ''; //
@nmyers
nmyers / gist:e8ba9dd50bd726c9bf9e
Created February 25, 2015 11:30
Equal height divs
function equalHeight(elem) {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = [],
$el,
topPosition = 0;
$(elem).each(function() {
$el = $(this);
$($el).height('auto');
topPostion = $el.position().top;
@nmyers
nmyers / acf-map.php
Last active February 19, 2020 06:56
ACF Static google map with link #acf #wp
<?php
$location = get_field('location');
if( !empty($location) ):
?>
<a href="http://www.google.com/maps/preview#!q=<?=urlencode( $location['address'] )?>">
<img src="http://maps.googleapis.com/maps/api/staticmap?center=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&zoom=15&format=png&sensor=false&size=397x297&maptype=roadmap&visual_refresh=true&style=visibility:off&style=feature:road|element:geometry|visibility:simplified&style=feature:landscape|element:geometry|visibility:simplified&style=element:labels|visibility:on&markers=color:red|<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>"/>
</a>
<?php endif; ?>
@nmyers
nmyers / functions.php
Last active May 27, 2018 04:22
Submenu nav - wordpress #wp
// add hook
add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 );
// filter_hook function to react on sub_menu flag
function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) {
// global $wp_query;
// console_debug('post is single >>',is_single() ? 'yes' : 'no');
//console_debug('menu',$sorted_menu_items);
if (is_single()) {
@nmyers
nmyers / Sharer.php
Last active March 24, 2017 17:01
Social share code
<div class="social-share" >
<ul>
<li><h6>SHARE:</h6></li>
<li><a class="twitter" target="_blank" href="https://twitter.com/share?url=<?=rawurlencode(get_permalink())?>&text=<?=rawurlencode(get_the_title().' – ')?>">
<span class="icon-twitter"></span><span class="visuallyhidden" >Twitter</span>
</a></li>
<li><a target="_blank" href="http://www.facebook.com/sharer.php?u=<?=rawurlencode(get_permalink())?>" >
<span class="icon-facebook"></span><span class="visuallyhidden" >Facebook</span>
</a></li>
<li><a target="_blank" href="/cdn-cgi/l/email-protection#650008040c09405755040101170016164057550d0017005a1610070f00061158595a58170412101709000b060a01004d42260d00060e45110d0c16450a10115f452b0009091c4527000b452d041c0a100b45361110010c0a4587e5f645424b0200113a110d003a110c1109004d4c4c5a5b43070a011c58595a58170412101709000b060a01004d0200113a1500170804090c0b0e4d4c4c5a5b">