Skip to content

Instantly share code, notes, and snippets.

View davidvandenbor's full-sized avatar

David van den Bor davidvandenbor

View GitHub Profile
@davidvandenbor
davidvandenbor / multiple-rss-feeds-wordpress.php
Created June 16, 2015 08:59
Multiple RSS feeds in WordPress
<?php
/**
* Class to return multiple RSS feeds in WordPress
* Instructions:
* 1. Upload this class to theme folder
* 2. Include this class in functions.php ie: include "mytheme/wow_rss.php";
*
* In theme template:
* 3. Create new object of class ie: $obj = new wow_Rss ("http://www.mywebsite.co.uk/feed","5");
* Enter feed url as 1st argument and how many items from that feed as the 2nd
@davidvandenbor
davidvandenbor / auto-generate-wp-featured-image.php
Last active August 29, 2015 14:24
Auto generate featured WP image
@davidvandenbor
davidvandenbor / foundation-animated-accordion.js
Created September 7, 2015 10:26
Foundation animated accordion
//reflow after page load
$(document).foundation('accordion', 'reflow');
//animate open/close
$(".accordion li").on("click", "a:eq(0)", function (event) {
var dd_parent = $(this).parent();
if(dd_parent.hasClass('active')) {
$(".accordion li ul.content:visible").slideToggle("normal");
} else {
@davidvandenbor
davidvandenbor / wp-mysql-url-replacement-queries.sql
Created September 26, 2015 13:17
WordPress MySql URL replacement queries
UPDATE wp_options SET option_value = replace(option_value, 'http://www.alpha-audio.nl', 'http://www.alpha-audio.dev') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.alpha-audio.nl','http://www.alpha-audio.dev');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.alpha-audio.nl', 'http://www.alpha-audio.dev');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.alpha-audio.nl','http://www.alpha-audio.dev');
@davidvandenbor
davidvandenbor / filter-wordpress-comment-form-fileds.php
Last active October 2, 2015 00:32
WordPress: filter comment form fields
<?php
function alter_comment_form_fields($fields){
//$fields['author'] = ''; //removes name field
//$fields['email'] = ''; //removes email field
//$fields['url'] = ''; //removes website field
return $fields;
}
add_filter('comment_form_default_fields','alter_comment_form_fields');
@davidvandenbor
davidvandenbor / category-title.php
Last active October 15, 2015 10:21
WordPress: show the category title
<h1><?php //single_cat_title() ?></h1>
<?php //echo str_replace('Categorie: ','',get_the_archive_title()); ?>
<?php //echo '<h1 class="page-title">' . single_cat_title( '', false ) . '</h1>'; ?>
@davidvandenbor
davidvandenbor / wordpress-remove-width-height-img-html.php
Last active November 4, 2015 10:03
WordPress: remove width and height attributes from imh html
<?php
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
?>
@davidvandenbor
davidvandenbor / wordpress-wrap-flex-video-class.php
Last active November 11, 2015 22:53
WordPress: wrap videos with Zurb Foundation flex-video class
<?php
/**
* -------------------------------------------------------------------------------//
* wrap video's with Zurb Foundation flex-video class div
* @author @david
* -------------------------------------------------------------------------------//
*/
add_filter('embed_oembed_html', 'david_embed_oembed_html', 99, 4);
function david_embed_oembed_html($html, $url, $attr, $post_id) {
return '<div class="flex-video widescreen">' . $html . '</div>';
@davidvandenbor
davidvandenbor / responsive-centered-google-maps.css
Last active November 20, 2015 13:35
Responsive centered Google Maps
.container {
max-width: 640px;
max-height: 640px;
margin: 0 auto
}
.google_map
{
width: 100%;
@davidvandenbor
davidvandenbor / html-insertion-jquery.js
Last active December 4, 2015 09:03
HTML code insertion in pages using jQuery
// this is how you can insert pieces of HTML code into pages using jQuery
var dynamic_html = "<div><span>Highlighted</span><span>Author</span></div>";
document.getElementByID("container").innerHTML = dynamic_html;