Variable image aspect ratio crop in WordPress

Posted in wordpress

To crop an image with a variable width/height, use ‘auto’ instead of pixels.  Here is the code to add to functions.php if ( function_exists( ‘add_image_size’ ) ) add_theme_support( ‘post-thumbnails’ ); if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘home-thumb’, 100, 100, true ); add_image_size( ‘featured’, 268, ‘auto’, true ); }

How to include prev/next navigation only when excerpts extend beyond one page

Posted in wordpress

If you don’t have enough blog posts to warrant previous/next page navigation, here is some simple code to include in index.php. This will prevent a broken link to a prev/next page that doesn’t yet exist. <?php   global $wp_query;   $total_pages = $wp_query->max_num_pages;   if ($total_pages > 1){   include (TEMPLATEPATH . ‘/inc/nav.php’ ); } ?>

Make a link open on double click

Posted in css

Great resource on Stack Overflow on how resolve the issue of mouse hover navigation on mobile devices. You lose the ability to hover over a link for a dropdown submenu. You need to click on top level navigation to display the submenu. Otherwise the click takes you directly to a link without displaying submenu. http://stackoverflow.com/questions/4562012/make-a-link-open-on-double-click […]

Window resize

Posted in jQuery

How to dynamically resize margins based on window size. Resource resize event Sample code <script type=”text/javascript” src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js”></script> <script type=”text/javascript”> //Initial load of page $(document).ready(sizeContent); //Every resize of window $(window).resize(sizeContent); //Dynamically assign height to .top and margin-bottom function sizeContent() { var newHeight = $(window).height() * .015 + “%”; var footerHeight = $(window).height() * .025 + “%”; […]

.htaccess

Posted in css

#to redirect a site set up for https to http EXCEPT for one folder. The commented out line is to except one page. I found that didn’t work as the images/css were not recognized as https which defeats the purpose. I ended up putting the one file I wanted as secure in a folder with […]

Contact Form 7 Integration with Email Before Download plugin

Posted in wordpress

The plugins Email Before Download and WordPress Download Monitor can be used in conjunction with Contact Form 7 to send a file upon form submission. http://wordpress.org/extend/plugins/email-before-download/ In order to have a pdf automatically sent after a form submission, you will need to upload the pdf via the “Downloads” link on the left. You need to […]

Placeholder text

Posted in jQuery

I noticed placeholder text in form fields wasn’t displaying on all browsers. Here’s a great jQuery plugin that solved the problem. http://mathiasbynens.be/demo/placeholder Github download: https://github.com/mathiasbynens/jquery-placeholder 

How to display different languages in php

Posted in php

PHP sometimes doesn’t want to display the characters of a different language. I use Dreamweaver as my text editor and recently I needed to add Chinese characters to a php navigation include. When I tried to add the characters within actual php code – Dreamweaver converted the characters into “????”. It worked fine when it […]

Jquery portfolio sorter

Posted in jQuery

An incredible plugin for portfolio sorter/filter http://isotope.metafizzy.co/

jQuery Show Hide

Posted in jQuery

http://www.aakashweb.com/resources/pages/demos/jquery-collapser/ http://www.adipalaz.com/experiments/jquery/expand.html