Snippets
-

Enable Redis on your Pantheon installation only to Test and Live environments.
-
Someone in our WPSerbia FB Page asked about different styles for first post in the loop, so this is the snippet for that. <?php if (have_posts()) : $counter = 1; while (have_posts()) : the_post(); if( $counter == 1 ) { ?> /* First post */ <? } elseif( $counter == 2 ) { ?> /*
-
If you are using iThemes Security (and I do recommend using it), make sure you go to Settings and under Brute Force Protection have “Immediately ban a host that attempts to login using the “admin” username.” checked. PS: And if YOU get locked out on your “admin” account, who knows why is that good, right? :)
-
This is how you can zip a folder via SSH on your Linux server. zip -r filename.zip foldername/
-
MM-DD-YYYY // this code will run for form 4 only; change 4 to your form ID add_filter(‘gform_validation_4’, ‘verify_minimum_age’); function verify_minimum_age($validation_result){ // retrieve the $form $form = $validation_result[‘form’]; // date of birth is submitted in field 7 in the format YYYY-MM-DD // change the 7 here to your field ID $dob = rgpost(‘input_7’); // this the
-
Twitter Boostrap 3, drop-down menu on hover. .dropdown-menu { .sub-menu { left: 100%; position: absolute; top: 0; visibility: hidden; margin-top: -1px; } li:hover .sub-menu { visibility: visible; } } .dropdown:hover .dropdown-menu { display: block; } .nav-tabs .dropdown-menu, .nav-pills .dropdown-menu, .navbar .dropdown-menu { margin-top: 0; } .navbar { .sub-menu:before { border-bottom: 7px solid transparent; border-left:
-
add_action( “bp_core_activated_user”, “bp_autologin_on_activation”, 40, 3 ); function bp_autologin_on_activation( $user_id, $key, $user) { global $bp, $wpdb; //simulate Bp activation /* Check for an uploaded avatar and move that to the correct user folder, just do what bp does */ if ( is_multisite() ) $hashed_key = wp_hash( $key ); else $hashed_key = wp_hash( $user_id ); /* Check
-
“You May Also Like”, code snippet for displaying list of posts from the same category on page: add_filter( ‘the_content’, function() { $id = get_the_id(); if ( !is_singular( ‘post’ ) ) { return $content; } $terms = get_the_terms( $id, ‘category’ ); $cats = array(); foreach ($terms as $term) { $cats[] = $term->cat_ID; } $loop = new
-
With MAMP PRO you can easily increase the PHP memory limit. Therefore you simply have to change some data within the php.ini file. Here is how it works: Start MAMP PRO Stop the server if it’s running Choose Menu -> File -> Edit Template -> PHP5 php.ini (If you want to change the memory limit for PHP5,
-
First launch Terminal app, and paste or type in the following command: defaults write com.apple.finder QLEnableTextSelection -boolean YES; Then restart the finder with the following command: killall Finder Source: http://www.cultofmac.com/216414/select-and-copy-text-right-in-quicklook-os-x-tips/