How To Add Custom Pinterest Button In Your WordPress Website
Using the following snippet will let you add custom pinterest button in your WordPress website.
Add to your header above the body tag
1 |
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script> |
Edit and add to your page where you want your button to appear.
1 |
<div class="socialIcon-box"><a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fyourdomain.com&media=<?php bloginfo(template_directory); ?>/images/youricon.png&description=Site%20Name%20and%20Description" class="pin-it-button" count-layout="horizontal"><img src="<?php bloginfo(template_directory); ?>/images/youricon.png" /></a></div> |
Snippet Source/Credit: flashalexander.com
How To Remove WordPress Standard Gallery Style
On simply adding the following snippet to your theme’s functions.php file, you will be able to remove WordPress standard gallery style.
1 |
add_filter( 'use_default_gallery_style', '__return_false' ); |
How To Resize Image Using TimThumb
Using the whole timthumb script, which being saved as sized.php file in the theme directory, you will be able to resize image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
function get_thumb_src($src, $width="100", $height="100", $quality="85", $alignment="", $zoomcrop="", $filters="", $sharpen="", $canvascolor="", $transparency=""){ if($src=="") return FALSE; $src = "src=".$src; $width = "&w=".$width; $height = "&h=".$height; $quality = "&q=".$quality; $alignment = (!empty($alignment)) ? "&a=".$alignment : ""; $zoomcrop = (!empty($zoomcrop)) ? "&zc=".$zoomcrop : ""; $filters = (!empty($filters)) ? "&f=".$filters : ""; $sharpen = (!empty($sharpen)) ? "&s=".$sharpen : ""; $canvascolor = (!empty($canvascolor)) ? "&cc=".$canvascolor : ""; $transparency = (!empty($transparency)) ? "&ct=".$transparency : ""; return get_template_directory_uri()."/sized.php?".$src.$width.$height.$quality.$alignment.$zoomcrop.$filters.$sharpen.$canvascolor.$transparency; } function the_thumb_src($src, $width="100", $height="100", $quality="85", $alignment="", $zoomcrop="", $filters="", $sharpen="", $canvascolor="", $transparency=""){ if($thumb = get_thumb_src($src, $width, $height, $quality, $alignment, $zoomcrop, $filters, $sharpen, $canvascolo, $transparency)){ echo $thumb; } } function get_thumb($src, $alt="", $classes="", $id=""){ return "<img class='".$classes."' id='".$id."' src='".$src."' alt='".$alt."' />"; } function the_thumb($src, $alt="", $classes="", $id=""){ echo get_thumb($src, $alt, $classes, $id); } function get_main_thumb($post_id, $alt="", $classes="", $id="", $width="", $height=""){ $src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), "full", false); if($src[0]=="") return FALSE; $width = ($width!="") ? $width : "750"; $height = ($height!="") ? $height : "250"; $src = get_thumb_src($src[0], $width, $height); return "<img class='".$classes."' id='".$id."' src='".$src."' alt='".$alt."' />"; } function the_main_thumb($post_id, $alt="", $classes="", $id="", $width="", $height=""){ if($thumb = get_main_thumb($post_id, $alt, $classes, $id, $width, $height)){ echo $thumb; } } |
Snippet Source/Credit: Binarymoon
How To Position Admin Metaboxes Before Editor
With the help of the snippet below, you will be able to position admin metaboxes before editor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function positioning_metaboxes() { global $post; if ( get_post_type($post) == 'post') { ?> <script type="text/javascript"> jQuery('#normal-sortables').insertBefore('#postdivrich'); </script> <?php } }; add_action( 'admin_footer', 'positioning_metaboxes' ); |
Snippet Source/Credit: Snipplr
How To Set Adjacent Post By Alphabetical Order
Using the following snippet will let you get next and previous posts by alphabetical order.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
function filter_next_post_sort($sort) { $sort = "ORDER BY p.post_title ASC LIMIT 1"; return $sort; } function filter_next_post_where($where) { global $post, $wpdb; return $wpdb->prepare("WHERE p.post_title > '%s' AND p.post_type = 'post' AND p.post_status = 'publish'",$post->post_title); } function filter_previous_post_sort($sort) { $sort = "ORDER BY p.post_title DESC LIMIT 1"; return $sort; } function filter_previous_post_where($where) { global $post, $wpdb; return $wpdb->prepare("WHERE p.post_title < '%s' AND p.post_type = 'post' AND p.post_status = 'publish'",$post->post_title); } add_filter('get_next_post_sort', 'filter_next_post_sort'); add_filter('get_next_post_where', 'filter_next_post_where'); add_filter('get_previous_post_sort', 'filter_previous_post_sort'); add_filter('get_previous_post_where', 'filter_previous_post_where'); |
Source: Snipplr
How To Simulate A View Of A Page With JavaScript Onclick
Using the following snippet, you will be able to simulate a view of a page with JavaScript onclick.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<input id="submit" onclick="trackpage('/kontaktudfyldt/')" type="submit" value="<?php _e('Send Email', 'framework') ?>" /> <script type="text/javascript"> // <![CDATA[ var readytosubmit = false; function trackpage (track) { _gaq.push(['_trackPageview',track]); readytosubmit = !readytosubmit; setTimeout(clicksubmit(), 100)} function clicksubmit() { document.getElementById("submit").click(); } // ]]> </script> |
Snippet Source/Credit: Reiffs.dk