Skip to content

Instantly share code, notes, and snippets.

View katmoody's full-sized avatar

Katrina Moody katmoody

View GitHub Profile
// Add Read More Link to Excerpts
add_filter('excerpt_more', 'get_read_more_link');
add_filter( 'the_content_more_link', 'get_read_more_link' );
function get_read_more_link() {
return '...&nbsp;<a href="' . get_permalink() . '">[Read&nbsp;More]</a>';
}
@katmoody
katmoody / Search Form in Specific WP Nav
Last active August 29, 2015 14:09
Adds search form to Specific Navigation with Theme Location - Replace "example.com" with your site's primary URL
add_filter('wp_nav_menu_items', 'add_search_form', 10, 2);
function add_search_form($items, $args) {
if( $args->theme_location == 'secondary' )
$items .= '<li class="search"><form method="get" class="search-form" action="http://example.com/" role="search"><input type="search" name="s" placeholder="Search..."><input type="submit" value="Search"></form></li>';
return $items;
}

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@katmoody
katmoody / README.md
Last active August 29, 2015 14:10 — forked from icryptic/README.md

WordPress database clean up queries

Orphan rows

Since WordPress uses MyISAM for it's storage engine, we don't get foreign keys - thus orphan rows can show themselves.

wp_posts -> wp_posts (parent/child)

SELECT * FROM wp_posts
LEFT JOIN wp_posts child ON (wp_posts.post_parent = child.ID)
/* Creates random keys for confirm checkbox */
function generate_confirm_key($length = 50) {
$characters = '-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
<?php
// add parameter html5=1 to oembed YouTube requests as per
// http://stackoverflow.com/questions/17747443/css-transform-translate-breaking-youtube-embedded-video
// using modified version of code on http://www.alittleofboth.com/2013/06/modifying-youtube-video-display-in-wordpress/
add_filter( 'oembed_result', 'youtube_oembed_html5_parameter', 10, 3);
function youtube_oembed_html5_parameter($data, $url, $args = array()) {
// add &html5=1 parameter
$data = preg_replace('/(youtube\.com.*)(\?feature=oembed)(.*)/', '$1?' . apply_filters("hyrv_extra_querystring_parameters", "feature=oembed&amp;html5=1&amp;") . 'rel=0$3', $data);
return $data;
}

The reason you might not be able to remove the Open Sans font that Wordpress >= 3.8 adds to the frontend is that quite a few WP styles and scripts list 'open-sans' as a dependancy when being registered and enqueued. When you remove the 'open-sans' style the other plugins dependant on it will not load. So you just need to deregister WP's open sans style and register your own, with a false value for the src like below.

Credit to seventhsteel from http://wordpress.org/support/topic/turning-off-open-sans-for-the-38-dashboard

@katmoody
katmoody / remove-genesis-entry-title-link.php
Last active August 29, 2015 14:20 — forked from joshuadavidnelson/remove-genesis-entry-title-link.php
Changing to add link to enable underline effect
<?php
/**
*
* Remove Links from Post Titles in Genesis
*
* @author Joshua Nelson
* @link http://joshuadnelson.com
*
*/
@katmoody
katmoody / kat-fonticon
Last active August 29, 2015 14:21
Register and Enqueue FontIcons, using native WordPress function
// Register fonticon script
wp_register_script( 'kat-fonticon', 'https://use.fonticons.com/91a2525c.js', array(), null, false );
//* Enqueue scrip with Altitude Pro theme
add_action( 'wp_enqueue_scripts', 'kat_enqueue_scripts_styles' );
function kat_enqueue_scripts_styles() {
wp_enqueue_script( 'kat-fonticon' );
// Add other scripts and/or CSS here if it has already been registered
}
<?php
/**
* Grid Content
* Change the number of words in excerpt if in the grid loop
*/
function be_grid_content() {
// First, we make sure we're in the grid loop.
if( ! apply_filters( 'is_genesis_grid_loop', false ) )
return;