Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
add_shortcode('shortcode_find_takeaway', 'shortcode_find_takeaway');
function shortcode_find_takeaway() {
$terms = get_terms( array(
'taxonomy' => 'towns-takeaway',
'hide_empty' => false,
) );
if ( $terms && ! is_wp_error( $terms ) ) :
// http://www.wpbeginner.com/wp-tutorials/how-to-use-shortcodes-in-your-wordpress-sidebar-widgets/
add_filter('widget_text','do_shortcode');
add_shortcode('shortcode_find_restaurant', 'shortcode_find_restaurant');
function shortcode_find_restaurant() {
$terms = get_terms( array(
'taxonomy' => 'towns-restaurant',
'hide_empty' => false,
@celticwebdesign
celticwebdesign / WordPress - Woocommerce tracking code
Created March 7, 2017 11:47
Add Woocommerce products tracking code before main Google Analytics code in header.php
header.php
<?php
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
// echo $wp->query_vars['order-received'];
// Lets grab the order
$order = wc_get_order( $wp->query_vars['order-received'] );
https://code.tutsplus.com/articles/customizing-your-wordpress-admin--wp-24941
http://stackoverflow.com/questions/11298251/swap-array-values-with-php
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
$temp = $menu_ord[3];
$menu_ord[3] = $menu_ord[4];
$menu_ord[4] = $temp;
@celticwebdesign
celticwebdesign / Showing loading animation until iFrame loads
Created January 25, 2017 10:22
This code was used to test for a third-party booking system iframe, upon loading the availability, remove the loading animation and show iframe availability results.
HTML ----
<div class="container well checking" style="max-width:700px">
<h3>We are now searching for your desired availability</h3>
<img src='images/loading.svg' alt='Loading availability' width='120' height='120'>
// loading.svg made at: http://loading.io/
add_meta_box('nme_pro_reviews_box', 'Property Reviews', 'nme_pro_reviews_box', 'property', 'normal', 'high');
$("img.lazy").lazyload({
effect : "fadeIn",
threshold : 200,
event : "sporty"
});
$('#order_az').click(function() {
$("img.lazy").trigger('sporty');
});
<?php
// // WordPress method - Start
// function get_json( $url, $arg ) {
// //GET remote site
// $response = wp_remote_get( $url, $arg );
// //Checking for errors
// if ( is_wp_error( $response ) ) {
// return sprintf( 'Your URL %1s could not be retrieved', $url );
http://snipplr.com/view.php?codeview&id=70656
# First:
DELETE FROM wp_postmeta
WHERE post_id IN
(
SELECT id
FROM wp_posts
WHERE post_type = 'attachment'