Skip to content

Instantly share code, notes, and snippets.

View ellegaarddk's full-sized avatar

ellegaarddk ellegaarddk

View GitHub Profile
@ellegaarddk
ellegaarddk / remove-metainfo-on-posts.php
Last active May 29, 2017 07:30
Wordpress Genesis - change / remove meta info pon posts
<?php
/** Customise the post-info function */
add_filter( 'genesis_post_info', 'genesischild_post_info' );
function genesischild_post_info($post_info) {
if (!is_page()) {
$post_info = 'Posted on [post_date] Written by [post_author] [post_comments] [post_edit]'; //Edit to relevant text
//$post_info = ''; //To remove text
return $post_info;
}
}
@ellegaarddk
ellegaarddk / URL_change.sql
Last active April 22, 2018 12:58
Skift af URL til https
##Ret prefix og domæner!!!!
UPDATE wp_posts SET post_content = replace(post_content, 'http://domain.dk', 'https://domain.dk');
UPDATE wp_posts SET guid = REPLACE (guid, 'http://domain.dk', 'https://domain.dk') WHERE post_type = 'attachment';
UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'http://domain.dk', 'https://domain.dk');
UPDATE wp_comments SET comment_content = replace(comment_content, 'http://domain.dk', 'https://domain.dk');
@ellegaarddk
ellegaarddk / functions.php
Created August 23, 2018 09:11
WordPress: Remove not needed widgets from Genes framework by StudioPress
/**
* Unregister Genesis widgets
*
* Include in theme's functions.php or create your own functions plugin
* Comment out needed widgets
*/
function eid_rem_genesis_widgets() {
unregister_widget( 'Genesis_eNews_Updates' );
// unregister_widget( 'Genesis_Featured_Page' );
// unregister_widget( 'Genesis_Featured_Post' );
@ellegaarddk
ellegaarddk / rename_CTP_title.php
Last active October 22, 2018 17:16
Omdøb titelfelt i Custom Post Type
function change_default_title( $title ){
$screen = get_current_screen();
if ( $screen->post_type == 'your_custom_post_type' ) {
return __( Skriv din egen tekst her', 'lang_domain' );
}
}
add_action('init', 'change_default_title');
@ellegaarddk
ellegaarddk / slider_cpt.php
Created October 22, 2018 17:44
creating custom post type for frontpage slider
<?php
/* creating custom post type for frontpage slider
* By ellegaard ID - www.eid.dk
*/
add_action('init', 'create_frontpagepic');
function create_frontpagepic() {
$feature_args = array(
'labels' => array(
'name' => __( 'Forsidebilleder' ),
@ellegaarddk
ellegaarddk / woo_change_tab_titel_desc.php
Last active November 2, 2018 10:15
Change Woocommerce description tab title to product name
<?php
// This wil cheange the title (Description) of the description tab to product name
add_filter( 'woocommerce_product_tabs', 'eid_change_product_description_tab_title', 10, 1 );
function eid_change_product_description_tab_title( $tabs ) {
global $post;
if ( isset( $tabs['description']['title'] ) )
$tabs['description']['title'] = $post->post_title;
return $tabs;
}
@ellegaarddk
ellegaarddk / change_product_description_tab_title.php
Last active November 2, 2018 11:09
This will change the title (Description) of the description tab to something else - here 'Event information'. Use a suitable txt_domain for translations.
<?php
/* This will change the title (Description) of the description tab to something else
* @origin https://wp-pro.dk/guides/tilpas-woocommerce-faneblades-titel-og-overskrift
*/
add_filter( 'woocommerce_product_tabs', 'eid_change_product_description_tab_title', 10, 1 );
function eid_change_product_description_tab_title( $tabs ) {
global $post;
if ( isset( $tabs['description']['title'] ) )
$tabs['description']['title'] = __('Event information', 'txt_domain'); // change for something else, ready for translation
@ellegaarddk
ellegaarddk / functions.php
Created November 2, 2018 12:14
Special functions for this website that shouldn't be put in the child theme
<?php
/*
Plugin Name: Functions for my website
Plugin URI: https://wp-pro.dk/lav-dit-eget-funktionsplugin/
Description: Special functions for this website without their own plugin
Version: 1.5
Author: Ellegaard ID
Author URI: http://www.eid.dk
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ellegaarddk
ellegaarddk / woo_change_tab_headline_desc.php
Last active March 6, 2019 16:56
Change Woocommerce tab title and/or description to something else - or nothing
<?php
/* This will change the heading (H2:Decstiption) within the description tab to product name
* @origin https://wp-pro.dk/guides/tilpas-woocommerce-faneblades-titel-og-overskrift
*/
add_filter( 'woocommerce_product_description_heading', 'eid_change_product_description_tab_heading', 10, 1 );
function eid_change_product_description_tab_heading( $title ) {
global $post;
return $post->post_title; //change to "" to remove text
}
@ellegaarddk
ellegaarddk / wpml_show_default.php
Last active March 6, 2019 16:57
Show default version if translation isn't found
<?php
add_filter('icl_ls_languages', 'wpml_ls_filter');
function wpml_ls_filter($languages) {
global $sitepress;
$default_url = $languages[$sitepress->get_default_language()]['url'];
foreach($languages as $lang_code => $language){
if($languages[$lang_code]['missing']==1){
$languages[$lang_code]['url'] = $default_url;