Add Currency to Woocommerce
Add this code to your functions.php file:
function add_my_currency( $currencies ) {
$currencies["IDR"] = 'Rupiah';
return $currencies;
}
add_filter( 'woocommerce_currencies', 'add_my_currency', 10, 1 );
Add Watermark to Textbox using jQuery
jQuery(document).ready(function() {
var watermark = "Type the code seen above";
jQuery(".wpcf7-captchar").val(watermark);
jQuery(".wpcf7-captchar").focus(function() {
if (jQuery.trim(jQuery(".wpcf7-captchar").val()) == watermark) {
jQuery(".wpcf7-captchar").val("");
}
});
jQuery(".wpcf7-captchar").blur(function() {
if (jQuery.trim(jQuery(".wpcf7-captchar").val()) == "") {
jQuery(".wpcf7-captchar").val(watermark);
}
});
});
Retina Display Media Query
For including high-res graphics, but only for screens that can make us of them. “Retina” being “2x”:
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { /* Retina-specific stuff here */ }
Custom WordPress RSS Feeds
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php'); // the file to rss feed generator
$feed = fetch_feed('http://www.brettthompsonracing.com/feed/'); // specify the rss feed
$limit = $feed->get_item_quantity(7); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>
// The actual output
<h1><a href="<?php echo $item->get_permalink(); ?>" alt="<?php echo $item->get_title(); ?>"><?php echo $item->get_title(); ?></a></h1>
<p><?php echo $item->get_date('j F Y @ g:i a'); ?></p>
<p><?php echo substr($item->get_description(), 0, 200); ?> ...</p>
<?php endforeach; ?>
IE Table fixed width
This thing with IE almost get me bold. I cannot set the width of a table property for example:
table td { width:50px; }
This won’t work only in IE7. Finally I found this blog post that give the property needed by IE7 to set the width of the table property
table-layout: fixed;
It works like a charm for me.
note: to all IE user, please use other browsers.
Force custom post type to be private
function force_type_private($post) { if ($post['post_type'] == 'my_post_type') $post['post_status'] = 'private'; return $post; } add_filter('wp_insert_post_data', 'force_type_private');
Recent Comments