Skip to content

Instantly share code, notes, and snippets.

@conor-egan
conor-egan / Add a class to menu item
Created January 15, 2014 10:04
Adds the class news_page_parent to the <li> with the given class
<script>
jQuery(document).ready(function($){
$("li.menu-item-171").addClass("news_page_parent");
});
</script>
/* Custom Excerpt */
// Remove default hellip
function carawebs_remove_hellip( $more ) {
$return = str_replace('[...]', '', $more);
return $return;
}
add_filter('excerpt_more', 'carawebs_remove_hellip');
/* Custom Excerpt */
// Remove default hellip
function carawebs_remove_hellip( $more ) {
return '';
}
add_filter('excerpt_more', 'carawebs_remove_hellip');
@conor-egan
conor-egan / Customise WordPress excerpt
Last active March 28, 2023 03:15
Remove hellip and final punctuation from a WordPress excerpt (includes rtrim function)
/* Custom Excerpt */
// Remove default hellip
function carawebs_remove_hellip( $more ) {
return '';
}
add_filter('excerpt_more', 'carawebs_remove_hellip');
@conor-egan
conor-egan / Prevent WordPress redirecting to homepage with empty search
Created January 16, 2014 16:57
Prevent WordPress redirecting to homepage with empty search
@conor-egan
conor-egan / Full background image
Created January 20, 2014 17:03
Style background image on a website that covers the entire browser window at all times.
html {
background: url(your-image-here) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@conor-egan
conor-egan / Responsive fixed background image
Last active January 3, 2016 21:59
Responsive fixed background image
<Body>
<img src ="http://conoregan.com/wp-content/uploads/2014/01/2013-12-04-08.50.18.jpg" class="background">
<div class="wrapper">
<p>Page content</p>
</div>
</body>
//CSS:
.wrapper{
@conor-egan
conor-egan / Read text and create directories
Created May 20, 2014 14:43
Bash script to read text file and create new directories
###################################################################
# Code cycles through a text file and creates a directory for every line in the file
# with the contents of the line the title of the directory
###################################################################
#! /bin/bash
while read line # while there are lines in the file
do
mkdir -p $line # create a new directory in the working directory titled with the #value of the line
done <filename.txt # filename.txt should be the name of the text file you are reading
@conor-egan
conor-egan / custom-fields-img-change
Created July 4, 2014 10:04
Change background image with custom fields
<?php if (is_page() || is_single()) {
<?php $background = get_post_meta($post->ID, 'background', true);
if ($background) {
?>
<style type="text/css">body{ url(<?php echo $background; ?>) no-repeat fixed; }</style>
<?php }
}?>