Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
HTML
<?php
$rows_sr = get_field('staff_repeater');
if($rows_sr) {
echo "
@celticwebdesign
celticwebdesign / removeattr.js
Created February 1, 2016 08:45
Remove img alt and title after full page download.
$(window).load(function() {
$('.class_name_here img').removeAttr( "title" ).removeAttr( "alt" );
});
@celticwebdesign
celticwebdesign / click_telephone.php
Last active July 20, 2016 14:29
Read options telephone number and make it international for mobile devices.
<?php
function click_telephone($telephone, $string = null, $prepend = null, $prepend_zero = null) {
/*
Parameters:
$telephone - string, the actual number
$string - string, if you want to dispay a clickable strong rather than telephone number,
$prepend - string, prepend the telephone number.
$countrycode - string, country code or default UK 0044
@celticwebdesign
celticwebdesign / Fancybox-open-on-page-load.php
Created February 13, 2016 22:34
Fancybox open on page load
JS ----
(function ($, root, undefined) {
$(function () {
if ($('body.home').length > 0 ) {
$.fancybox({
'width': '100%',
'height': '100%',
@celticwebdesign
celticwebdesign / Page-scroll-on-page-load.php
Created February 13, 2016 22:35
Page scroll on page load
CSS ----
// Competition Valentines 2016
// if( $('body.valentines-day-win-a-bottle-of-bubby-and-a-50-voucher').length > 0 ) {
// var type = window.location.hash.substr(1);
// if( type == "competition" ) {
// $('html, body').animate({
// scrollTop: $("#mc_embed_signup").offset().top
// }, 2000);
// }
// }
<?php
global $post;
$author_id=$post->post_author;
// echo gettype( $author_id );
// echo "<pre>";
// print_r( $author_id );
// echo "</pre>";
// https://codex.wordpress.org/Function_Reference/the_author_meta
@celticwebdesign
celticwebdesign / PhotoSwipe - Object Passing - WordPress
Created March 5, 2016 12:04
Passing an object through JSON from PHP to JS, to use in PhotoSwipe.js. Allows different photo widths and heights in PhotoSwipe lightbox. See 'View image gallery' on littlewhitealice.co.uk/our-cottages/fearn-the-alder-house/
Passing an object through JSON from PHP to JS, to use in PhotoSwipe.js
Allows different photo widths and heights in PhotoSwipe lightbox
See 'View image gallery' on littlewhitealice.co.uk/our-cottages/fearn-the-alder-house/
---- HTML
$output .= "<div class='flexslider'>
<ul class='slides'>";
@celticwebdesign
celticwebdesign / Add box shadow to header on scroll
Created March 21, 2016 11:17
Add box shadow to header on scroll
$( window ).scroll(function() {
// if ($('body').not('.home').length > 0 ) {
if( $(window).scrollTop() > 0 ) {
$('#header').css('box-shadow', '0 1px 3px rgba(0, 0, 0, 0.5)');
} else {
$('#header').css('box-shadow', 'none');
}
// }
});
@celticwebdesign
celticwebdesign / Get a post of parent category
Created March 22, 2016 21:35
Get a post of parent category (of another post)
<?php
$category = get_the_category();
// echo $category[0]->category_parent;
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'post__not_in' => array( get_the_ID() ),
@celticwebdesign
celticwebdesign / WordPress adjust loop query
Created April 15, 2016 13:21
WordPress adjust loop query - used on FHC search.php
<?php
global $query_string;
query_posts($query_string . "&post_type=document");
?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>