This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wdt_redirect_brand() { | |
$uri = $_SERVER['REQUEST_URI']; | |
if( !is_user_logged_in() ) { | |
if ( strpos( $uri, '/brand/') === 0 ) { | |
$r301 = str_replace( '/brand/', '/marke/', $uri ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE wp_postmeta AS sku | |
JOIN (SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key = '_ts_gtin') AS gtin USING (post_id) | |
SET sku.meta_value = gtin.meta_value | |
WHERE sku.meta_key = '_sku' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function( $ ) { | |
$( '.et_pb_toggle' ).hover(function() { | |
$( this ).children( 'h5' ).trigger( 'click' ); | |
}); | |
})( jQuery ); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode( 'techtable', function () { | |
$techdata = get_post_meta( get_the_ID(), 'technische_daten', true ); | |
if( $techdata ) { | |
$out = '<table>'; | |
$lines = explode( "\n", $techdata ); | |
foreach( $lines as $line ){ | |
$out .= '<tr>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function redirect_to_url() { | |
switch ( $_SERVER['REQUEST_URI'] ) { | |
case '/an-old-uri/': | |
$redirect_to = '/the-new-uri/'; | |
break; | |
case '/another-old-uri/': | |
$redirect_to = '/another-new-uri/'; | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Shortcode to Display Post Tags in UnorderedList /w specific CSS-Class and Link to Archive | |
=============================================================== */ | |
function display_tags( $atts, $content = null ) { | |
$post_tags = get_the_tags(); | |
if ( $post_tags ) { | |
$html = '<ul class="tag-list">'; | |
foreach( $post_tags as $tag ) { | |
$html .= '<li><a class="' . $tag->slug . '" href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* adding og:image for Facebook shares | |
=============================================================== */ | |
add_action( 'wp_head', function(){ | |
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); | |
if ($featured_image) { | |
echo '<meta property="og:image" content="'.$featured_image[0].'">'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('woocommerce_shop_loop_item_title','brands_to_item_title', 11); | |
function brands_to_item_title( ) { | |
$brands = wp_get_post_terms( get_the_ID(), 'product_brand' ); | |
if ( count( $brands ) > 0 ) { | |
foreach( $brands as $brand ) | |
echo '<span class="brand-name">' . $brand->name . '</span>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_single_product_summary', 'add_brand_to_single_product_summary', 6 ); | |
function add_brand_to_single_product_summary() { | |
global $post; | |
if ( ! $post_id && ! $post ) | |
return; | |
if ( ! $post_id ) | |
$post_id = $post->ID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function redirectTo( $location ) { | |
header( 'HTTP/1.1 301 Moved Permanently' ); | |
header( 'Location: ' . $location ); | |
header( 'Connection: close' ); | |
} | |
switch ( $_SERVER['REQUEST_URI'] ) { | |
case '/post/an-uri-on-old-domain': | |
redirectTo( 'https://new-domain.com/a-new-uri/' ); | |
break; |