Skip to content

Instantly share code, notes, and snippets.

@brandonhimpfen
brandonhimpfen / functions.php
Created May 28, 2014 18:34
Display the content of one page in another page.
function get_post_page_content( $atts ) {
extract( shortcode_atts( array(
'id' => null,
'title' => false,
), $atts ) );
$the_query = new WP_Query( 'page_id='.$id );
while ( $the_query->have_posts() ) {
$the_query->the_post();
@brandonhimpfen
brandonhimpfen / menu-panel.php
Created February 1, 2014 19:54
Display a WordPress menu as a Twitter Bootstrap list group panel. Make sure to change the panel title, text and on line 2 - change the "menu-id"
echo '<div class="panel panel-default"><div class="panel-heading">Title Goes Here</div><div class="panel-body"><p>Description or whatever you want goes here.</p></div><ul class="list-group nav">';
wp_nav_menu( array( 'container' => false, 'menu_class' => 'list-group-item', 'theme_location' => 'menu-id', 'after' => '', 'items_wrap' => '%3$s' ));
echo '</ul></div>';
@brandonhimpfen
brandonhimpfen / last-posts.php
Created February 1, 2014 19:42
Creates a list group of the last 5 posts in WordPress, using Twitter's Bootstrap panel. More or less of 5 posts? Change line 2.
echo '<div class="panel panel-default"><div class="panel-heading">Last Five Posts</div><div class="panel-body"><p>Here are the latest posts:</p></div><ul class="list-group nav">';
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="'.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> ';
}
echo '</ul></div>';
@brandonhimpfen
brandonhimpfen / wordpress-login-page.css
Created January 15, 2014 16:03
A Germany themes WordPress login page
body.login {
background: #000;
}
body.login div#login {
color: #ae8400;
}
body.login div#login a {
color: #fff;
}
body.login div#login a:hover {
@brandonhimpfen
brandonhimpfen / wordpress-login-page.css
Created January 14, 2014 20:34
Example WordPress login page CSS that I use for one of my travel sites.
body.login {
background: #428bca;
}
body.login div#login {
color: #fff;
}
body.login div#login a {
color: #fff;
}
body.login div#login a:hover {
@brandonhimpfen
brandonhimpfen / gist:7867901
Created December 9, 2013 05:56
Disable WordPress cron - add to your wp-config.php file.
define( 'DISABLE_WP_CRON', true );
@brandonhimpfen
brandonhimpfen / .htaccess
Created December 1, 2013 01:00
Force the WWW at the Beginning of the URL
# Rewrite example.com → www.example.com
# Use with caution, as this may cause subdomains to forward as well.
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteCond %{HTTP_HOST} !=localhost [NC]
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@brandonhimpfen
brandonhimpfen / .htaccess
Created December 1, 2013 01:00
Remove the WWW from the Beginning of the URL
# Rewrite www.example.com → example.com
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
@brandonhimpfen
brandonhimpfen / gist:7727327
Created December 1, 2013 00:59
Configure the Auto-Save Interval - add to your wp-config.php
define( 'AUTOSAVE_INTERVAL', 300 );
@brandonhimpfen
brandonhimpfen / gist:7727317
Created December 1, 2013 00:58
Enable Error Logging in WordPress- add to your wp-config.php
@ini_set('log_errors','On'); // enable or disable php error logging (use 'On' or 'Off')
@ini_set('display_errors','Off'); // enable or disable public display of errors (use 'On' or 'Off')
@ini_set('error_log','/public_html/path/wordpress/php-errors.log'); // path to server-writable log file