Skip to content

Instantly share code, notes, and snippets.

Jon Masterson JonMasterson

Block or report user

Report or block JonMasterson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
JonMasterson / gravity-form-with-post-meta
Last active Feb 9, 2017
Populate Gravity Form with email from post meta and output contact form on front end if the post author fills it out.
View gravity-form-with-post-meta
* Add Contact Meta Box to Posts, Pages, or Any Custom Post Type
* Adds a contact form to single post pages when filled out
* Get the Gravity Forms plugin, then
* put this is your functions file
$contact_meta_box = array(
'id' => 'jm-contact-meta-box',
'title' => 'Contact Email',
'context' => 'normal',
JonMasterson / Post Views
Created Jan 24, 2014
Display the number of post views on single posts (uses font awesome), just like
View Post Views
* Save number of views to post meta.
function sh_set_post_views($postID) {
$count_key = 'sh_post_views_count';
$count = get_post_meta( $postID, $count_key, true );
if( $count=='' ){
$count = 0;
delete_post_meta( $postID, $count_key );
add_post_meta( $postID, $count_key, '0' );
JonMasterson / alternate-function
Created Nov 5, 2013
Swap Font Awesome Icons based on the number of likes post receives. Can be used with my WordPress Like System.
View alternate-function
* Swap Function (5) with the following
* (5)(b) Front end button
function getPostLikeLink( $post_id ) {
$theme_object = wp_get_theme();
$themename = esc_attr( $theme_object->Name ); // the theme name
$like_count = get_post_meta( $post_id, "_post_like_count", true ); // get post likes
if ( ( !$like_count ) || ( $like_count && $like_count == 0 ) ) { // no votes, set up empty variable
You can’t perform that action at this time.