Skip to content

Instantly share code, notes, and snippets.

/*
Theme Name: twentysixteen Child Theme
Theme URI: https://rm314.com
Description: A bare-bones child theme for use with twentysixteen Theme.
Author: Jimmy Knoll
Author URI: http://jimmyknoll.com/
Template: twentysixteen
Version: 1.0.0
*/
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
// exclude pages from search
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
// shortcode to show related posts by tags
function related_posts_shortcode( $atts ) {
extract(shortcode_atts(array(
'limit' => '5',
), $atts));
global $wpdb, $post, $table_prefix;
// enable shortcodes in widgets
add_filter('widget_text', 'do_shortcode');
// create column shortcodes
function rm314_one_third( $atts, $content = null ) {
return '<div class="one_third">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_third', 'rm314_one_third');
function rm314_one_third_last( $atts, $content = null ) {
return '<div class="one_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
}
add_shortcode('one_third_last', 'rm314_one_third_last');
//disabling WordPress’s auto-formating filters ( get rid of p tags, br tags, etc.. )
function rm314_formatter($content) {
$new_content = '';
/* Matches the contents and the open and closing tags */
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
/* Matches just the contents */
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
//Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553
@ini_set('pcre.backtrack_limit', 500000);
/*styles responsive column shortcodes*/
.one_half {
width: 48%;
border: solid 1px #eee
}
.one_third {
width: 30.66%;
border: solid 1px #eee
}
.two_third {
function rm314_column_stylesheet() {
$my_style_url = WP_PLUGIN_URL . '/rm314_column_shortcodes/styles.css';
$my_style_file = WP_PLUGIN_DIR . '/rm314_column_shortcodes/styles.css';
if ( file_exists($my_style_file) ) {
wp_register_style('column-styles', $my_style_url);
wp_enqueue_style('column-styles');
}
}
add_action('wp_print_styles', 'rm314_column_stylesheet');