Skip to content

Instantly share code, notes, and snippets.

@davechu
davechu / Show latest Post update person in Post Info
Last active August 29, 2015 14:25
This can be used to show the "latest updater" instead of the original Post Author. Adjust additional text to taste. I added spaces to separate the name from other info.
add_filter( 'genesis_post_info', 'dc_post_info_filter' );
function dc_post_info_filter($post_info) {
$var = do_shortcode('[post_comments zero="No Comments" one="1 Comment" more="% Comments"]');
$post_info = 'Updated by ' . get_the_modified_author() . '&nbsp &nbsp &nbsp' . $var;
return $post_info;
}
@davechu
davechu / Tastefully hide accessibility links
Created June 25, 2015 14:42
This CSS allows "extra" headings and other items to be hidden from sighted viewers. Avoiding "display: none;" preserves the intended accessibility. Obviously adjust these selectors to match your site. "Clip" is deprecated, but the newer "clip-path" is poorly-supported at this time.
@davechu
davechu / Style first level of main WordPress menu with Font Awesome.
Created May 29, 2015 14:55
Style to taste for spacing. For example, vertical-align "middle" or a positive or negative pixel amount. The nice trick is to avoid styling submenu items, thanks to selectors. This gives a down-arrow that could indicate a submenu. If some menu items aren't dropdowns, you could get more specific with li.menu-item-333 or the like.
ul#menu-top-navigation-menu > li > a:after {
content: "\f107";
font-family: 'FontAwesome';
font-size: 27px;
padding-left: 12px;
speak: none;
}
add_filter( 'comment_form_defaults', 'dc_remove_comment_form_allowed_tags' );
function dc_remove_comment_form_allowed_tags( $defaults ) {
$defaults['comment_notes_after'] = '';
return $defaults;
}
@davechu
davechu / Add comment form to Sensei private message area on "One" theme.
Last active August 29, 2015 14:16
This goes in your edited copy of content_single_message.php just after the line containing "the_content".
<?php comment_form(); ?>
add_action('sensei_comments', 'dc_do_comments_form');
function dc_do_comments_form() {
comment_form();
}
@davechu
davechu / For Regula: sidebar fix by overriding plugin CSS
Last active August 29, 2015 14:15
This code should go into style.css. Appearance... Edit. Just be careful not to edit other lines.
@media (min-width: 769px) and (max-width: 1024px) {
#inner .sidebar { margin-left: 0;}
}
@davechu
davechu / Change Read Me link
Created January 28, 2015 15:55
Change the Read More text to something else in WordPress. Example is en français. This code would go into your functions.php. It could also work in a plugin.
@davechu
davechu / Making the Body Schema attribute HTTPS
Created November 24, 2014 14:10
For Dipak. These are hardcoded, but this example shows that you can replace them. See more attributes to alter in \genesis\lib\functions\markup.php
/** I'm also wondering if plain "//" may also work, the idea to make the URL security-agnostic, so to speak. **/
add_filter( 'genesis_attr_body', 'dc_dipak_body_attr' );
function dc_dipak_body_attr( $attributes ) {
$attributes['itemtype'] = 'https://schema.org/WebPage';
return $attributes;
}
@davechu
davechu / Change Lang on WordPress HTML tag
Last active August 29, 2015 14:09
For Rogier. This would go in your functions.php. Be careful, this will replace all occurrences of that string. Otherwise, make a custom template. :)
add_filter( 'language_attributes', 'dc_change_html_lang' );
function dc_change_html_lang( $attributes ) {
if ( is_page(42) ) {
$attributes = str_replace("nl-NL", "en", $attributes );
}
return $attributes;
}