Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / myThoughts.md
Created September 8, 2017 15:45
Display PHP output on a WordPress page

Context

https://twitter.com/felafel/status/906162644125659136

@salcode Met you at WC Lancaster. Looking to embed existing php code (not a snippet) in a WP page. Tried a few plugins. Suggestion?

My Thoughts

Displaying PHP output on a WordPress page can vary depending on where you want to display the output.

@salcode
salcode / 2017-nearby-wordcamps.md
Last active October 5, 2017 22:45
2017 WordCamps Near Me
@salcode
salcode / wp-auto-update-everything.php
Last active November 29, 2021 10:08
By default, WordPress only automates minor versions of core when there is no VCS information present. This code enables auto-updates for everything (core, plugins, and themes).
<?php
/**
* Enable Auto Updates for Everything
* https://gist.github.com/salcode/b60df55598c21c5970600a56715a2b1c
*
* Please put this file in the `mu-plugins` directory.
*
* curl -O https://gist.githubusercontent.com/salcode/b60df55598c21c5970600a56715a2b1c/raw/wp-auto-update-everything.php
*/
@salcode
salcode / yoast-setup-notes.md
Last active August 10, 2016 17:26
Note to self when setting up Yoast SEO

Setting Up Yoast SEO

  • Enable Twitter cards: /wp-admin/admin.php?page=wpseo_social#top#twitterbox Enable and Summary with Large Image
  • Change Title separator to |
@salcode
salcode / fe-prevent-slug-conflict.php
Created July 19, 2016 04:15
WordPress code to reserve some top level Permalink slugs.
<?php
/**
* Prevent top level permalink slugs that will cause conflicts.
*
* New rewrite slugs are introduced when CPTs or Custom Taxonomies are created.
* This code adds a check when Pages or Posts are created, that their Permalink
* does not conflict with one of the reserved top level slugs you define.
*
* In the case of a bad (i.e conflicting slug), WordPress appends a "-2" to
* the permalink.
<?php
/**
* Set the number of posts on the Custom Post Type archive for `fe_recipe` to 5.
*/
add_action( 'pre_get_posts', 'fe_modify_number_of_posts_per_page' );
/**
* Modify Posts Per Page for CPT `fe_recipe`
*
<?php
/**
* The code to register a WordPress Custom Post Type (CPT) `fe_recipe`
* with a custom Taxonomy `fe_recipe_tag`
* @package fe_recipe
*/
add_action( 'init', 'fe_recipe_cpt' );
/**
@salcode
salcode / minimal-cpt-definition.php
Last active January 21, 2020 15:41
Minimal WordPress code to register the Custom Post Type `fe_recipe`
<?php
/**
* Register CPT `fe_recipe`
*/
add_action( 'init', 'fe_recipe_cpt' );
/**
* Register CPT `fe_recipe`
*/
@salcode
salcode / home.php
Created June 14, 2016 10:15
Genesis home.php template to display content before posts on blog page.
<?php
/**
* File for home.php
*
* Blog page template with page description before blog posts.
*
* @package example;
*/
add_action( 'genesis_before_loop', 'fe_home_genesis_before_loop' );
@salcode
salcode / populate-blank-comment.js
Created June 9, 2016 14:12
jQuery JavaScript to populate a blank comment with an Automated Comment. This is being done on the client side because on the server side there is no filter available before the check for an empty comment body.
jQuery('#commentform').on('submit', function() {
var $comment = jQuery('#comment');
if ( '' === $comment.val().trim() ) {
$comment
.css({'color':'#fff'})
.val( 'Automated Comment: ' + Math.floor( new Date().getTime() / 1000 ) );
}
});