Skip to content

Instantly share code, notes, and snippets.

View MortenAndersen's full-sized avatar

Morten Andersen MortenAndersen

View GitHub Profile
@MortenAndersen
MortenAndersen / gist:2ec171f43080e85ecdaa
Created October 30, 2015 13:01 — forked from rutger1140/gist:5576437
Clean up WordPress wp_nav_menu
<?php
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
@MortenAndersen
MortenAndersen / Wordpress: Do if the_content is not empty
Last active July 1, 2017 19:04 — forked from bhongy/Wordpress: Do if the_content is not empty
Wordpress: Check om der findes indhold i the_content
<?php
$content = get_the_content();
if(!empty($content)) { ?>
<div class="content">
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
</div>
<?php } ?>
@MortenAndersen
MortenAndersen / product-tag.php
Last active September 25, 2015 15:22 — forked from ChromeOrange/product-tag.php
WooCommerce : display products in a tag. Add to your theme functions.php file
/**
* List products in a product tag shortcode
* Useage : [product_tag tag="foo"]
*/
add_shortcode( 'product_tag', 'woocommerce_product_tag' );
function woocommerce_product_tag( $atts ){
global $woocommerce, $woocommerce_loop;
if ( empty( $atts ) ) return;
/* Daniel Ott
* entities.css
* 31 January 2011
*
* Adding arrows to thinks makes them more clickable. Right?
* Use CSS's :after pseudo-selector to insert hexadecimal values
* of html entities into the document. Less markup. More awesome.
*/
.add-an-arrow:after {
/**
* Implements hook_form_alter().
*
* Courtesy of JohnAlbin
*/
function THEMENAME_form_search_block_form_alter(&$form, &$form_state) {
$form['actions']['submit']['#type'] = 'image_button';
$form['actions']['submit']['#src'] = drupal_get_path('theme', 'THEMENAME') . '/images/button-search.png';
}
@MortenAndersen
MortenAndersen / index.html
Created August 16, 2013 08:39
A CodePen by Morten Andersen. Calendar
<ul class="kalender">
<li>
<a href="#">
<div class="dato">
<span>10</span><b>feb</b> 2013
</div>
<div class="kalender-text">
<h3>Posten kom til tiden...</h3>
<p>stormøde for postomdelere fra hele København og omegn. Godt 150 medlemmer var mødt op, hvilket gjorde til et af de største medlems</p>
</div>
@MortenAndersen
MortenAndersen / dabblet.css
Created May 16, 2012 21:21
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #fff;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
color: #000000