Skip to content

Instantly share code, notes, and snippets.

View stebrech's full-sized avatar

Stefan Brechbühl stebrech

View GitHub Profile
@stebrech
stebrech / change_login_logo.php
Created November 30, 2012 14:32
Ersetze das WordPress Logo auf der Login-Seite mit deinem eigenem Logo.
function custom_login_logo() {
echo
'<style type="text/css">
h1 a {
background-image:url('.get_site_url().'/wp-content/uploads/login.png) !important;
background-size: 100% auto !important;
margin-left: 8px !important;
width: 312px !important;
}
</style>';
@stebrech
stebrech / moving_wordpress
Created June 13, 2013 17:54
Moving WordPress: 1. Replacing WordPress’ base URL path. 2. Update the GUID that controls WordPress’ translating paths and post locations. 3. Update the URL paths in the content. 4. Update the URLs in the meta data of posts, such as attachments.
UPDATE wp_options SET option_value = replace(option_value, 'http://localhost:8888/wordpress', 'http://www.YOUR_SITE_URL.com') WHERE option_name = 'home' OR option_name = 'siteurl';
@stebrech
stebrech / excerpt_readmore.php
Last active December 26, 2015 17:19
Custom excerpt read more link
<?php function excerpt_readmore($more) {
return '... <a href="'. get_permalink($post->ID) . '" class="readmore">' . 'Read More' . '</a>';
}
add_filter('excerpt_more', 'excerpt_readmore'); ?>
@stebrech
stebrech / Deaktiviere WP Galerie head styles
Created December 27, 2013 03:08
Styling von WordPress-Galerien über die functions.php ausschalten
add_filter( 'use_default_gallery_style', '__return_false' );
@stebrech
stebrech / wp_auto_twitter_links.php
Last active January 3, 2016 22:19
Automatische Verlinkung von Twitter-Benutzernamen.
@stebrech
stebrech / back-to-top.js
Created January 22, 2014 16:25
Button um mit einer Animation an den Seitenanfang zu gelangen. Benötigt jQuery.
// Back To Top
$('a.top').click(function(){
$(document.body).animate({scrollTop : 0},800);
return false;
});
//Create an anchor tag
<a class=”top” href=”#”>Back to top</a>
@stebrech
stebrech / bilder-geladen.js
Created January 22, 2014 16:27
Überprüft ob Bilder geladen wurden. Benötigt jQuery
$(‘img’).load(function() {
console.log(‘image load successful’);
});
@stebrech
stebrech / wp_ad_after_2nd_paragraph.php
Created February 17, 2014 15:40
WordPress Snippet um Werbung, z.B. AdSense, nach dem zweiten Absatz eines Posts einzublenden. Source: http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/
<?php
//Insert ads after second paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = '<div>Ads code goes here</div>';
@stebrech
stebrech / wp_neue_bildformate_media_uploader.php
Created February 18, 2014 17:12
WordPress Snippet (für functions.php oder Plugin). Werden zu den Standardgrössen zusätzliche Bildformate definiert, werden diese nicht im Media-Uploader angezeigt. Blogartikel: http://www.pixelstrol.ch/blog/2014/02/wp-snippet-alle-bildgroessen-im-medien-uploader-anzeigen/ Quellen: http://wp-snippets.com/show-custom-image-sizes-in-admin-media-upl…
<?php
function show_image_sizes( $sizes ) {
$new_sizes = array();
$added_sizes = get_intermediate_image_sizes();
// $added_sizes is an indexed array, therefore need to convert it
// to associative array, using $value for $key and $value
foreach( $added_sizes as $key => $value) {
$new_sizes[$value] = $value;
@stebrech
stebrech / wp_excerpt_weiterlesen_link.php
Last active August 29, 2015 13:56
WordPress Snippet (für functions.php oder Plugin). Dieses Snippet fügt dem Auszug (Excerpt) in jedem Fall ein Weiterlesen-Link hinzu. Quelle: http://www.transformationpowertools.com/wordpress/read-more-on-all-excerpts-in-wordpress