Skip to content

Instantly share code, notes, and snippets.

@FriendlyWP
FriendlyWP / functions.php
Created October 26, 2013 00:54
Shortcode to insert current year.
/* SHORTCODE WHICH INSERTS CURRENT YEAR
* usage: [year]
*/
add_shortcode('year', 'year_shortcode');
function year_shortcode() {
$year = date('Y');
return $year;
}
@FriendlyWP
FriendlyWP / functions.php
Created October 26, 2013 00:52
Bold words in widget titles using underscore + asterisk (_* word *_).
// REPLACE _* *_ WITH <STRONG> HTML IN WIDGET TITLES
// usage: _*This*_ word is bold
add_filter( 'widget_title', function($title) {
$title = str_replace('_*', '<strong>', $title);
$title = str_replace('*_', '</strong>', $title);
return $title;
} );
@FriendlyWP
FriendlyWP / functions.php
Created October 26, 2013 00:49
WordPress SEO by Yoast tweaks
// FILTER WORDPRESS SEO BY YOAST outputs in the WordPress control panel
// remove WP-SEO columns from edit-list pages in admin
add_filter( 'wpseo_use_page_analysis', '__return_false' );
// put WP-SEO panel at bottom of edit screens (low priority)
add_filter('wpseo_metabox_prio' , 'my_wpseo_metabox_prio' );
function my_wpseo_metabox_prio() {
return 'low' ;
}
@FriendlyWP
FriendlyWP / functions.php
Created October 26, 2013 00:44
Display content with a word limit
/**
* Display specified content with a word limit
* Can be used for excerpts, full content, etc.
* In your theme file, use thus to display 40 words of the excerpt:
* $excerpt = get_the_excerpt();
* echo string_limit_words( $excerpt, 40 );
*
* @param string $string A variable containing the content you wish to display.
* @param num $word_limit The number of words to display.
* @return string Content limited to the number of words specified.
@FriendlyWP
FriendlyWP / posts-to-posts-list-widget.php
Created November 23, 2012 18:15
Posts 2 Posts List Widget
<?php
/*
Plugin Name: Posts 2 Posts List Widget
Plugin URI: http://friendlywebconsulting.com/
Description: Creates a widget to display posts connected via the Posts 2 Posts plugin by Scribu, found here: http://wordpress.org/extend/plugins/posts-to-posts/
Author: Michelle McGinnis
Author URI: http://friendlywebconsulting.com/
Version: 1.0.0-alpha
*/