Skip to content

Instantly share code, notes, and snippets.

<?
//=========================================================== SUBSCRIBER SHORTCODE
function subscriber_shortcode($atts, $content = null ) {
extract(shortcode_atts(array(
'page' => '',
'headline' => 'Subscribe for free updates',
'button' => 'Subscribe',
'quote' => '',
'class' => 'box_main',
'form_class' => 'centered_form',
<?php
//=========================================================== Grab first paragraph (two if first is not long enough)
function get_first_two_paragraphs(){
global $post;
$str = wpautop( get_the_content() );
$psToGrab = 2; // number of paragraphs to get
$maxFirstParaLength = 200; // character max in first paragraph
$matches = array(); // matching elements will go here
$pattern = '%<p[^>]*>(.*?)</p>%i'; // match what's between all <p> tags
preg_match_all($pattern, $str, $matches); // do the regex match
@chasereeves
chasereeves / gist:2a36fd3cf02844eef47f
Created March 4, 2015 19:59
Fizzle Soundcloud Shortcode
// [podsc url="069-work-for-yourself-or-for" hrtop="" hrbottom="" btn_top=""]
function podsc($atts) {
extract(shortcode_atts(array(
"url" => '',
"hrtop" => 'true',
"hrbottom" => 'true',
"btn_top" => ''
), $atts));
// remove intro bits of URL if it's in the shortcode
@chasereeves
chasereeves / Wordpress Function: Social Meta Tags for Open Graph.php
Created November 24, 2015 17:18
Wordpress Function: Social Meta Tags for Open Graph
function insert_fb_in_head() {
global $post;
if ( !is_singular()) return;
$meta = strip_tags($post->post_content);
$meta = strip_shortcodes($post->post_content);
$meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
$meta = substr($meta, 0, 125);
$meta = strip_tags($meta);
// basics, same for all
// [quotable]"Here's my quote."[/quotable]
// [quotable link="" class="" link_class=""]"Here's my quote."[/quotable]
// if link says 'no', use only content, no permalink
//=========================================================== TWEET THIS SHORTCODE
function quotable_shortcode( $atts, $content = null ) {
extract(shortcode_atts(array(
'class' => 'no_lede',
'link' => '',
'link_class' => '',
), $atts));