Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Root-Wiley mrwweb

View GitHub Profile
View Extend_WP_Query.php
<?php
// Resuable instance of WP_Query with preset $args
class Extended_WP_Query extends WP_Query {
function __construct( $args = array() ) {
$args = wp_parse_args( $args, array(
// some $args go here for reuse
) );
@mrwweb
mrwweb / reset-rems
Created May 22, 2013
"Sanity-ize" REMs by setting them to 10px-baseline aka "Tiny Happy Pixels Dancing."
View reset-rems
/* this is the "root" in "root em." */
html {
font-size: 62.5%; /* Now 10px = 1rem! */
}
body {
font-size: 16px; /* px fallback */
font-size: 1.6rem; /* default font-size for document */
line-height: 1.5; /* a nice line-height */
}
@mrwweb
mrwweb / hide_yoast_seo_meta.php
Created Jun 1, 2013
Hide Yoast SEO Metabox via Screen Options by Default for New Users
View hide_yoast_seo_meta.php
// Hide Yoast SEO by Default
function hide_yoast( $hidden ) {
$hidden[] = 'wpseo_meta';
return $hidden;
}
add_filter( 'default_hidden_meta_boxes', 'hide_yoast' );
@mrwweb
mrwweb / readme.md
Last active Dec 18, 2015
Two helper functions to handle common use-cases for outputting fields created with Advanced Custom Fields.
View readme.md
@mrwweb
mrwweb / wordpress_posts_list.php
Created Jun 12, 2013
A function to output a delimited list of posts given an array of IDs in WordPress
View wordpress_posts_list.php
<?php
/**
* Make a list of links to WordPress posts
*
* Works great with the Relationship field from Advanced Custom Fields
*
* @param array $posts array of post objects or post_ids
* @param string $sep separater
* @param string $before output before the list
* @param string $after output after the list
@mrwweb
mrwweb / functions.php
Created Sep 20, 2013
Jetpack Buggy Featured Content Code
View functions.php
<?php
add_image_size( 'wcp-front-feature', 440, 300, true );
add_theme_support( 'featured-content', array(
'featured_content_filter' => 'wcp_featured_posts',
'max_posts' => 2,
) );
function wcp_get_featured_posts() {
View wordpress-3.8-dashicons.php
function flexslider_hg_admin_icon()
{
echo '
<style>
/*
Selectors:
1. Admin Menu
2. "Site Content" Dashboard Widget (Post Types only)
*/
#adminmenu #menu-posts-slides div.wp-menu-image:before,
@mrwweb
mrwweb / Title Attribute.html
Created Jan 21, 2014
Link with Title Attribute
View Title Attribute.html
<a href="http://google.com" title="Google">Google</a>
@mrwweb
mrwweb / mrw-tinymce-filter-example.php
Last active Sep 1, 2022
A plugin to modify the TinyMCE editor in WordPress 3.9+. Now available on WP.org! https://wordpress.org/plugins/mrw-web-design-simple-tinymce/
View mrw-tinymce-filter-example.php
<?php
/**
* Example filter to add text style to TinyMCE filter with Mark's "MRW TinyMCE Mods" plugin
*
* Adds a "Text Styles" submenu to the "Formats" dropdown
*
* This would go in a functions.php file or mu-plugin so you don't have to modify the original plugin.
*
* $styles array Contains arrays of style_format arguments to define styles.
* Note: Should be an "array of arrays"
@mrwweb
mrwweb / append-file-types.css
Created Jun 9, 2014
CSS to automatically add a filetype to the end of a link. (e.g. "[PDF]") This is a best practice for accessibility and usability. Add or remove types as you see fit.
View append-file-types.css
/* ID Link Mimetypes for Common Filetypes */
a[href$=".doc"]::after {
content: " [DOC]";
}
a[href$=".docx"]::after {
content: " [DOCX]";
}
a[href$=".rtf"]::after {
content: " [RTF]";