WordPress tip: Get rid of unused shortcodes
Mar 15, 2010 CSS, HTML, JavaScript, PHP, Tutorials, Wordpress
Simply run the following SQL query on your WordPress database, using the command line client or PhpMyAdmin. In this example, I assume the unused shortcode is [tweet] . Don’t forget to backup your database before using this query.
Direct Link Read the rest of this entry »
Tags: banner, Code, contribute, CSS, Database, forum, JavaScript, order, purchase, SQL, themes
WordPress tip: Get rid of unused post revisions
Mar 9, 2010 CSS, HTML, JavaScript, PHP, Tutorials, Wordpress
Just run the following query on your WordPress database, and all revisions (As well as meta associated with it) will be deleted from your database. Of course, do not forget to make a backup of your database before running the code. DELETE a,b,c FROM wp_posts a WHERE a.post_type = ‘revision’ LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id); If you’d like to see more SQL queries for WordPress, make sure to read this post .
Direct Link Read the rest of this entry »
Tags: archives, article, banner, Code, contribute, CSS, Database, forum, HTML, JavaScript, order, repeat, SQL, themes, Tutorials
WordPress plugin: Protect your blog from malicious URL Requests
Mar 4, 2010 CSS, HTML, JavaScript, PHP, Tutorials, Wordpress
Paste the following code into a text file, and save it as blockbadqueries.php. Once done, upload it to your wp-content/plugins directory and activate it like any other plugins. That’s all! <?php /* Plugin Name: Block Bad Queries Plugin URI: http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/ Description: Protect WordPress Against Malicious URL Requests Author URI: http://perishablepress.com/ Author: Perishable Press Version: 1.0 */ global $user_ID; if($user_ID) { if(!current_user_can(‘level_10′)) { if (strlen($_SERVER['REQUEST_URI']) > 255 || strpos($_SERVER['REQUEST_URI'], "eval(") || strpos($_SERVER['REQUEST_URI'], "CONCAT") || strpos($_SERVER['REQUEST_URI'], "UNION+SELECT") || strpos($_SERVER['REQUEST_URI'], "base64")) { @header("HTTP/1.1 414 Request-URI Too Long"); @header("Status: 414 Request-URI Too Long"); @header("Connection: Close"); @exit; } } } ?> Thanks to Jeff Starr for this great plugin! Do you know that Digging into WordPress , Jeff’s book, has just been updated?
Direct Link Read the rest of this entry »
Tags: archives, article, banner, canvas-theme, contribute, CSS, HTML, JavaScript, order, PHP, purchase, Security, themes, wordpress-discounts
WordPress tip: Create a PDF viewer shortcode
Mar 1, 2010 CSS, General, HTML, JavaScript, PHP, Tutorials, Wordpress
The first step is to paste the following code into your functions.php file: function pdflink($attr, $content) { return ‘<a class="pdf" href="http://docs.google.com/viewer?url=’ . $attr['href'] . ‘">’.$content.’</a>’; } add_shortcode(‘pdf’, ‘pdflink’); Once you saved the file, you’ll be able to use the shortcode on your posts and page.
Direct Link Read the rest of this entry »
Tags: archives, article, canvas-theme, contribute, CSS, forum, HTML, order, pdf, purchase, repeat, shortcode, themes, Tutorials, wordpress-discounts
WordPress trick: Change theme programatically
Feb 22, 2010 CSS, General, HTML, JavaScript, PHP, Tutorials, Wordpress
The first thing you have to do is to paste the following function in your functions.php file. function switchTheme($theme) { global $wpdb; if (isset($theme)) { $queries = array("UPDATE wp_options SET option_value = ‘default’ WHERE option_name = ‘template’;", "UPDATE wp_options SET option_value = ‘default’ WHERE option_name = ’stylesheet’;", "UPDATE wp_options SET option_value = ‘default’ WHERE option_name = ‘current_theme’;"); foreach ($queries as $query){ $wpdb->query($query); } } } What I’ve done in the function was simply to update the wp_options table (change the prefix if necessary) with a new theme name. You probably noticied that I used queries in a loop, which isn’t a good practice.
Direct Link Read the rest of this entry »
Tags: article, canvas-theme, contribute, CSS, forum, HTML, order, PHP, repeat, Tutorials, wordpress-discounts
How to display custom post types on your WordPress blog homepage
Feb 17, 2010 CSS, HTML, JavaScript, PHP, Tutorials, Wordpress
The following code have to be pasted in your functions.php file. Once the file will be saved, it will work. As you can see in the code, the post , page , album , movie , quote , and attachment types will be displayed.
Direct Link Read the rest of this entry »
Tags: article, canvas-theme, contribute, CSS, forum, HTML, JavaScript, justin-tadlock, order, purchase, repeat, themes, Tutorials, wordpress-discounts
How to remove “private” and “protected” from the post title
Feb 15, 2010 CSS, HTML, JavaScript, PHP, Tutorials, Wordpress
The only thing you have to do is to paste the following piece of code in your functions.php file. Once you’ll save the file, the hack will be applied to your your posts. function the_title_trim($title) { $title = attribute_escape($title); $findthese = array( ‘#Protected:#’, ‘#Private:#’ ); $replacewith = array( ”, // What to replace “Protected:” with ” // What to replace “Private:” with ); $title = preg_replace($findthese, $replacewith, $title); return $title; } add_filter(‘the_title’, ‘the_title_trim’); Credits goes to Chris Coyier for this awesome piece of code.
Direct Link Read the rest of this entry »
Tags: article, banner, contribute, CSS, forum, hack, protected, purchase
WordPress tip: Insert posts programmatically
Feb 10, 2010 CSS, General, HTML, JavaScript, PHP, Tutorials, Wordpress
Just paste the following code anywhere on WordPress theme files. If you want to test, I recommend pasting it in your functions.php file. That’s all you have to do.
Direct Link Read the rest of this entry »
Tags: article, Code, contribute, CSS, forum, HTML, order, related, repeat, wordpress-discounts
How to automatically use resized images instead of originals
Feb 7, 2010 CSS, General, HTML, JavaScript, PHP, Tutorials, Wordpress
Simply paste the following code on your functions.php file and save it. No other action is needed! function replace_uploaded_image($image_data) { // if there is no large image : return if (!isset($image_data['sizes']['large'])) return $image_data; // paths to the uploaded image and the large image $upload_dir = wp_upload_dir(); $uploaded_image_location = $upload_dir['basedir'] . ‘/’ .$image_data['file']; $large_image_location = $upload_dir['path'] .
Direct Link Read the rest of this entry »
Tags: archives, contribute, Design, forum, JavaScript, oops, PHP, purchase, themes, Tutorials, wordpress-discounts






