Skip to content

Instantly share code, notes, and snippets.

View dcooney's full-sized avatar

Darren Cooney dcooney

View GitHub Profile
@dcooney
dcooney / gist:6902392
Created October 9, 2013 14:41
Animation Mixin.
@mixin animation($value){
-webkit-animation: #{$value};
-moz-animation: #{$value};
-ms-animation: #{$value};
-o-animation: #{$value};
animation: #{$value};
}
@dcooney
dcooney / gist:7793397
Created December 4, 2013 19:00
Get related posts by tag in WordPress
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
$tag_in = array();
foreach($tags as $tag):
setup_postdata($tag);
$tag_in[] = $tag->slug;
endforeach;
$the_tags = implode(",", $tag_in); //Create
@dcooney
dcooney / gist:7793554
Created December 4, 2013 19:09
Remove 'Customize' menu item from WordPress admin.
//Remove Customize.php
function remove_sub_menus () {
remove_submenu_page('themes.php', 'customize.php'); //Customize
}
add_action('admin_menu', 'remove_sub_menus');
@dcooney
dcooney / gist:8692729
Created January 29, 2014 17:25
Show scrollbars in webkit
::-webkit-scrollbar { width: 10px; color: #a3a499; }
::-webkit-scrollbar-track { background-color: #ecede3; border-radius: 10px; border: 1px solid #d8d9cf; }
::-webkit-scrollbar-thumb { border-radius: 10px; background-color: #a3a499; }
@dcooney
dcooney / gist:8944353
Created February 11, 2014 21:15
WP Merged Search
$url = $_SERVER['REQUEST_URI'];
$parts = parse_url($url);
parse_str($parts['query'], $query);
$term = $query['term'];
$q1 = get_posts(array(
'post_type' => 'project',
'posts_per_page' => -1,
's' => $term,
));
@dcooney
dcooney / gist:10754700
Created April 15, 2014 18:13
WP Hide admin bar for subscribers
//Hide admin bar
// Place in functions.php
global $current_user;
get_currentuserinfo();
if ( user_can( $current_user, "subscriber" ) ){
add_filter('show_admin_bar', '__return_false');
}
@dcooney
dcooney / gist:f58244e86f8e054acec2
Created April 30, 2014 14:47
Get post id by slug and language
function get_page_id($page_name){
global $wpdb;
$sql = 'SELECT ID FROM '.$wpdb->posts.' LEFT JOIN '.$wpdb->wp_icl_translations.' WHERE post_name = "'.$page_name.'" AND language_code = "'.ICL_LANGUAGE_CODE.'"';
$page_name = $wpdb->get_var($sql);
return $page_name;
}
@dcooney
dcooney / gist:f3ad7ca0d7a6866e9a21
Created May 2, 2014 19:30
WordPress Ajax Login Shortcode
[wp_ajax_login]
@dcooney
dcooney / gist:65202bcee048a07a7805
Created May 9, 2014 18:36
Hightlight search term WordPress
<?php
$title = get_the_title();
$title_keys= explode(" ",$term);
$title = preg_replace('/('.implode('|', $title_keys) .')/iu', '<span class="highlight">\0</span>', $title);
echo $title;
?>
@dcooney
dcooney / gist:9b037efbd166b4dba5ae
Last active June 11, 2016 12:59
Exclude posts from Ajax Load More
<?php
$features = array('1, 1530', '1514', '1471'); // Array of posts
if($features){
//Implode the posts and set a varible to pass to our exclude param.
$post__not_in = implode(",", $features);
}
echo do_shortcode('[ajax_load_more post__not_in="'.$post__not_in.'"]');
?>