Skip to content

Instantly share code, notes, and snippets.

Morten Strand Hauge hauge75

View GitHub Profile
@hauge75
hauge75 / functions.php
Last active Feb 29, 2020
White label Soliloquy slider
View functions.php
// Register sliderstyle sheet.
//add_action( 'wp_enqueue_scripts', 'theme_register_slider_style' );
/**
* Register style sheet.
*/
/*
function theme_register_slider_style() {
wp_register_style( 'slider', get_stylesheet_directory_uri() . '/css/slider.min.css', 'soliloquy-style-css' );
wp_enqueue_style( 'slider' );
@hauge75
hauge75 / single-product.php
Created Jan 30, 2018
Woocoomerce if in stock
View single-product.php
global $product;
if ($product->is_in_stock()) {
//Do if product is in stock
}
View wordpress-passwort-reset-unmultisite.php
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/
@hauge75
hauge75 / functions.php
Created Jul 18, 2016
Rename slug for existing custom post type in childtheme - Wordpress
View functions.php
//* change slug for post type
$args = get_post_type_object("post_type_name");
$args->rewrite["slug"] = "new_slug";
register_post_type($args->name, $args);
@hauge75
hauge75 / functions.php
Created Jun 10, 2016
Change WordPress Email “Send From” Settings
View functions.php
function mail_filter_wp_mail_from($email){
return "your@email.com";
}
add_filter("wp_mail_from", "mail_filter_wp_mail_from");
@hauge75
hauge75 / functions.php
Created Apr 20, 2016
Give double weight to current and future events in relevanssi search (Relevanssi & Events Manager)
View functions.php
add_filter('relevanssi_match', 'date_weights');
function date_weights($match) {
$EM_Event = em_get_event($match->doc, 'post_id');
$enddate = $EM_Event->event_end_date;
$yesterday = time() - 24*60*60;;
if (strtotime($enddate) > $yesterday) {
$match->weight = $match->weight * 2;
}
else {
@hauge75
hauge75 / functions.php
Last active Apr 30, 2016
Changes the text labels for Google Calendar and iCal buttons on a single event page for The Events Calendar by Modern Tribe
View functions.php
<?php
// Changes the text labels for Google Calendar and iCal buttons on a single event page
remove_action('tribe_events_single_event_after_the_content', array('Tribe__Events__iCal', 'single_event_links'));
add_action('tribe_events_single_event_after_the_content', 'customized_tribe_single_event_links');
function customized_tribe_single_event_links() {
if (is_single() && post_password_required()) {
return;
}
@hauge75
hauge75 / functions.php
Last active Apr 11, 2016
Redirects wordpress author archives
View functions.php
<?php
//Redirects author archives, DON'T check "Disable Extra User Archives" in iThemes security
add_action( 'template_redirect', 'my_redirect_author_archive' );
function my_redirect_author_archive() {
if ( is_author() ) {
wp_redirect( home_url(), 302 );
exit;
}
@hauge75
hauge75 / functions.php
Created Apr 11, 2016
WPML language selector in menu - hide current language
View functions.php
<?php
// Filter wp_nav_menu() to add additional links and other output
add_filter('wp_nav_menu_items', 'new_nav_menu_items', 10, 2);
function new_nav_menu_items($items, $args) {
// add $args->theme_location == '[location]' in the conditional if we want to specify the menu location.
if (function_exists('icl_get_languages') && $args->theme_location == 'primary-menu') {
$languages = icl_get_languages('skip_missing=0');
if(!empty($languages)){
You can’t perform that action at this time.