Skip to content

Instantly share code, notes, and snippets.

@dbridgman
dbridgman / ACF - True or False Statement
Created September 2, 2016 09:31
A simple true false statement that uses an Advanced Custom Fields checkbox that will execute a piece of code if a checkbox is ticked.
<?php if ( get_field( 'featured_post' ) ): ?>
<li class="grid-item grid-item-half">
<?php
get_template_part('project-archive-content');
?>
</li>
<?php else: // field_name returned false ?>
@dbridgman
dbridgman / Hide Default Wordpress Editor Depending On Template
Created August 4, 2016 15:24
Hide Default Wordpress Editor Depending On Template
/**
* Hide editor for specific page templates.
*
*/
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
@dbridgman
dbridgman / HTTPS Redirect for Wordpress
Created April 14, 2016 09:49
Ensure this is placed at the top of the .htaccess file.
####################
###HTTPS REDIRECT###
####################
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@dbridgman
dbridgman / Smooth Anchor Scrolling
Created April 1, 2016 15:22
A simple jQuery script that will allow for smooth scrolling on a page when clicking on an anchor point.
<!-- ENSURE BELOW PASTES DIRECTLY INTO THE HEAD OF THE PAGE -->
<!-- SMOOTH SCROLL -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
<!-- MENU HTML -->
<div class="main-nav">
<nav>
<ul>
<li><a href="/" title="Blinds Southampton">Home</a></li>
<li><a href="/about.php" title="About Solaris">About</a></li>
<li><a href="javascript:void(0)" title="Products">Products</a>
<ul>
<li><a href="/vertical-blinds.php" title="Vertical Blinds">Vertical Blinds</a></li>
@dbridgman
dbridgman / wordpress-dropdown.css
Created February 15, 2016 12:19 — forked from joshuacharleslake/wordpress-dropdown.css
Wordpress Dropdown Menu CSS
.menu-header-menu-container li,
div.menu li {
float: left;
position: relative;
}
.menu-header-menu-container ul ul {
display: none;
position: absolute;
top: 38px;
<!-- BELOW IS THE CONTAIN THAT HOLDS THE MAP, YOU CAN DICTATE THE SIZE HERE -->
<div class="mapcontainer"><div id="map-canvas" style="height:400px; width:100%;"></div></div>
<script>
function initialize() {
// THE myLatlng VARIABLE DEFINES WHERE THE RADIUS IS GOING TO LAND
var myLatlng = new google.maps.LatLng(52.487600, -1.892821);
// THE myHome VARIABLE DEFINES WHERE THE PIN IS GOING TO LAND
var myHome = new google.maps.LatLng(52.699866, -1.991307);
var mapOptions = {
Get the skin folder
<?php echo $this->getSkinUrl('FOLDERNAME/FILENAME.png');?>
This can be used in lots of different contexts, here is an example:
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo $this->getSkinUrl('images/apple-touch.png');?>">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
.container {
width: 100%;
max-width: 500px;
max-height: 700px;
height: 700px;
position: relative;
border: 1px solid #ccc;
The if statement targets the URL
Add an ID to the target you want to add the class to,
Then enter it into the following line, alongside the name of the class you want:
"jQuery('#ID-NAME').addClass('CLASS-NAME');"
<!-- CODE TO USE IS BELOW -->
jQuery(function() {
var loc = window.location.href; // returns the full URL