Skip to content

Instantly share code, notes, and snippets.

@pascalmaddin
pascalmaddin / load_page_content.php
Last active December 15, 2015 00:59
WordPress - Loads the contents of another static page in WordPress
<?php
// Der Query für die Seite mit der ID 97 (als Beispiel)
$my_new_query = new WP_Query( 'page_id=97' );
// Loop starten
while ( $my_new_query->have_posts() ) : $my_new_query->the_post();
the_content();
endwhile;
// Und ein Reset - wichtig!
wp_reset_postdata();
?>
@pascalmaddin
pascalmaddin / increase_excerpt_field
Created June 11, 2013 08:30
WordPress - Increase the excerpt field height
<?php
add_action('admin_head', 'excerpt_textarea_height');
function excerpt_textarea_height() {
echo'
<style type="text/css">
#excerpt{ height:500px; }
</style>
';
}
?>
@pascalmaddin
pascalmaddin / related_posts_by_author
Created June 11, 2013 08:32
WordPress - Display related posts by posts current author
@pascalmaddin
pascalmaddin / add_lightbox_to_posts
Created June 11, 2013 08:34
WordPress - Add rel=”lightbox” to all images embedded in a post
<?php
add_filter('the_content', 'my_addlightboxrel');
function my_addlightboxrel($content) {
global $post;
$pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
$replacement = '<a$1href=$2$3.$4$5 rel="lightbox" title="'.$post->post_title.'"$6>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
?>
@pascalmaddin
pascalmaddin / change_input_text
Created June 11, 2013 08:35
WordPress - Change default “Enter title here” text within post title input field
<?php
function title_text_input( $title ){
return $title = 'Enter new title';
}
add_filter( 'enter_title_here', 'title_text_input' );
?>
@pascalmaddin
pascalmaddin / redirect_commenter
Created June 11, 2013 08:36
WordPress - Redirect commenter to thank you post or page
<?php
add_filter('comment_post_redirect', 'redirect_after_comment');
function redirect_after_comment(){
wp_redirect('/thank-you-page/');
exit();
}
?>
@pascalmaddin
pascalmaddin / parallax-image-with-text.html
Last active May 14, 2021 14:38
An Image with parallax-effect and with some text, which is fading out while scrolling
<div id="banner">
<div class="wrap-center">
<div class="banner-centered" id="banner-text">
<h2>Hello <strong>We Are Company-Name</strong>, Glad To See You. :-)</h2>
</div>
</div>
</div>
@pascalmaddin
pascalmaddin / js-slider.html
Created June 17, 2013 09:54
Really simple jQuery-Slider. Just the basic structure.
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>The Obligatory Slider</title>
<style>
body {
width: 600px;
margin: 100px auto 0;
}
@pascalmaddin
pascalmaddin / redirect_after_login.php
Created October 10, 2013 15:49
Leitet einen Nutzer nach der Registrierung auf eine beliebige Seite weiter
function __my_registration_redirect(){
return home_url( '/my-page' );
}
add_filter( 'registration_redirect', '__my_registration_redirect' );
@pascalmaddin
pascalmaddin / check_if_element_has_class.js
Created January 28, 2014 07:57
Here is a little snippet if you're trying to check wether element contains a class, without using jQuery. From http://sonnyt.com/javascript-check-if-element-has-class/
function hasClass(element, className) {
return element.className && new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className);
}