Skip to content

Instantly share code, notes, and snippets.

@pixelstrolch
pixelstrolch / wp_ad_after_2nd_paragraph.php
Created Feb 17, 2014
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/
View wp_ad_after_2nd_paragraph.php
<?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>';
@pixelstrolch
pixelstrolch / wp_neue_bildformate_media_uploader.php
Created Feb 18, 2014
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…
View wp_neue_bildformate_media_uploader.php
<?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;
@pixelstrolch
pixelstrolch / wp_excerpt_weiterlesen_link.php
Last active Aug 29, 2015
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
View wp_excerpt_weiterlesen_link.php
@pixelstrolch
pixelstrolch / wp_excerpt_more_string.php
Created Feb 23, 2014
WordPress Snippet (für functions.php oder Plugin). Ändere den more String im Auszug (Excerpt).
View wp_excerpt_more_string.php
<?php
function new_excerpt_more( $more ) {
return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');
?>
@pixelstrolch
pixelstrolch / albinomouse_alt_header.php
Last active Aug 29, 2015
An alternative header.php for the WordPress Theme AlbinoMouse v2.1.1. It puts the secondary navigation into the toggle menu on mobile devices.
View albinomouse_alt_header.php
<?php
/**
* The Header for AlbinoMouse.
* @package AlbinoMouse
*/
?>
<!DOCTYPE html>
<?php $options = get_option( 'albinomouse' ); ?>
<html <?php language_attributes(); ?>>
View wp_head_cleanup.php
<?php
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
?>
View wp_images_crop_dont_scale.php
<?php
// Standard Size Thumbnail
if(false === get_option("thumbnail_crop")) {
add_option("thumbnail_crop", "1"); }
else {
update_option("thumbnail_crop", "1");
}
// Medium Size Thumbnail
if(false === get_option("medium_crop")) {
View wp_spam_long_url.php
<?php
function url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
}
add_filter( 'pre_comment_approved', 'url_spamcheck', 99, 2 );
?>
View disable-wp-backend-editors.php
/*
* Files Editoren abschalten
*/
define('DISALLOW_FILE_EDIT',true);
@pixelstrolch
pixelstrolch / change_login_logo.php
Created Nov 30, 2012
Ersetze das WordPress Logo auf der Login-Seite mit deinem eigenem Logo.
View change_login_logo.php
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>';