Skip to content

Instantly share code, notes, and snippets.

@ginocremer
ginocremer / Page Slug in Body Classes WordPress
Created March 4, 2014 12:28
Page Slug in Body Classes WordPress
add_filter('body_class','body_class_section');
function body_class_section($classes) {
global $wpdb, $post;
if (is_page()) {
if ($post->post_parent) {
$parent = end(get_post_ancestors($current_page_id));
} else {
$parent = $post->ID;
}
$post_data = get_post($parent, ARRAY_A);
wp_register_script( 'cycle', 'http://malsup.github.com/jquery.cycle.all.js');
wp_enqueue_script( 'cycle' );
add_filter('widget_text', 'gibmirphp', 99);
function gibmirphp($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
<link rel="shortcut icon" href="/pfad/zum/favicon.ico">
function Pixelbar_AddSpellChecker($initArray){
$initArray['spellchecker_languages'] = '+Francais=fr, +Deutsch=de, English=en';
return $initArray;
}
add_filter('tiny_mce_before_init', 'Pixelbar_AddSpellChecker');
@ginocremer
ginocremer / Add Image Size WordPress
Created March 21, 2014 07:42
Add Image Size WordPress
add_image_size( 'neues-mass', 1600, 1200 );
@ginocremer
ginocremer / Aktivieren Sie die Beitragsbilder in der functions.php
Last active August 29, 2015 14:09
Praxis-Workshop: Theme-Entwicklung
add_theme_support( 'post-thumbnails' );
@ginocremer
ginocremer / gist:d911c7174bc0ade16f5e
Created November 22, 2014 21:32
SQL Anweisung Update Datenbank: Umzug WordPress
UPDATE wp_posts SET post_content = REPLACE ( post_content, 'http://127.0.0.1:8080/wordpress', 'http://www.mein-blog.info');
UPDATE wp_options SET option_value = REPLACE ( option_value, 'http://127.0.0.1:8080/wordpress', 'http://www.mein-blog.info');
@ginocremer
ginocremer / Eigene Farben pro Seite über eine eigene Body-Klasse
Created December 28, 2014 10:26
In vielen Fällen kann eine Klasse auf dem Body-Element nützlich sein. Zum Beispiel wenn Sie jeder einzelnen Seite eine eigene Farbgebung via CSS spendieren möchten.
function add_top_parent_body_class( $classes ) {
if(is_page()):
$top_id = '';
$ancestors = get_ancestors(get_the_ID(),'page');
if ( !empty($ancestors)):
$top_id = end($ancestors);
$classes[] = 'top-parent-'.sanitize_title(get_the_title($top_id));
else:
$classes[] = 'top-parent-'.sanitize_title(get_the_title(get_the_ID()));
endif;
@ginocremer
ginocremer / Exotische Dateitypen in Mediathek hochladen
Created December 29, 2014 21:37
Mit einem kleinen Snippet können Sie WordPress anweisen auch exotischere Dateitypen anstandslos anzunehmen.
add_filter('upload_mimes', 'add_custom_upload_mimes');
function add_custom_upload_mimes( $existing_mimes ){
$existing_mimes['zip'] = 'application/zip';
$existing_mimes['eps'] = 'application/eps';
$existing_mimes['rtf'] = 'text/richtext';
$existing_mimes['tiff'] = 'image/tiff';
return $existing_mimes;
}