Skip to content

Instantly share code, notes, and snippets.


Priscilla Chapman priscillamc

View GitHub Profile
priscillamc /
Last active Oct 4, 2019
Adding inline javascript in WordPress 4.5+ using wp_add_inline_script()

Adding Inline Scripts in WordPress

Since WordPress 4.5, you can add the inline JavaScript using the wp_add_inline_script() function. This can be used instead of echoing inline scripts using wp_footer. The first argument is the handle of a registered script, in this case 'pretty-photo'.

function add_styles_scripts(){
	// Add script in the footer
	wp_enqueue_script('pretty-photo', get_stylesheet_directory_uri() . '/.../jquery.prettyPhoto.js', 
		array('jquery'), NULL, true);

Display Featured Image, if exists (in loop)

if ( has_post_thumbnail() ){

Display theme image

<img src="<?php echo get_styleshet_directory_uri(); ?>/images/logo.png" class="" alt="" />
View wp-conditional-styles
* Add styles and scripts to a WordPress site
* See
function my_scripts_styles(){
global $wp_styles;
// Load IE version-specific stylesheets
wp_enqueue_style( 'html5shiv', '', array(), '3.7.2', 'screen' );
View bookmarks
# Bootstrap
# WordPress
View wp-simcal-gce-widget
<!-- Simple Calendar 3.0.4 - UF Template -->
<div class="event item">
<div class="eventdate event-date">
<div class="month">[start-date format="M"]</div>
<div class="day">[start-date format="j"]</div>
<div class="eventtitle">
[if-whole-day]<div class="time">All Day</div>[/if-whole-day]
[if-not-whole-day]<div class="time">[start-date format="g:i A"] - [end-date format="g:i A"]</div>[/if-not-whole-day]
priscillamc / wp-hide-customizer-admin-links
Created Aug 13, 2015
Remove WordPress Customizer links from the Admin Toolbar and dashboard by changing the body class back to 'no-customize-support'. This is a way to show only the original admin toolbar links for themes that don't support the Customizer.
View wp-hide-customizer-admin-links
View wp-auto-update-plugins-themes
Plugin Name: Auto Update
Description: Enables automatic background updates for core, plugins, and themes. See <a href="" target="_blank">Configuring Automatic Background Updates</a> for more details.
Version: 1.0.0
// Enable automatic updates for core major releases
add_filter( 'allow_major_auto_core_updates', '__return_true' );
View jquery.js
<script type="text/javascript">
// Your jQuery code here, using the $
priscillamc / git-email-fix
Created Apr 15, 2015
Git fix email settings in branch
View git-email-fix
git config --global
git config --global ""
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "" ];
git commit-tree "$@";
View custom plugin templates
// Use custom template pages in a WordPress plugin
function my_cpt_templates( $template_path ){
// Change template for CPT single pages
if( is_singular('my_cpt') ){
$template_path = plugin_dir_path( __FILE__ ) . 'templates/single-cpt.php';
// Change template for CPT archive pages for a certain taxonomy