Articles of optimization

What's faster? One big query, or several smaller ones?

I’m working on an app that will require a query, via Ajax, for a bunch of posts in random order. Something like this: $query = new WP_Query( array( ‘posts_per_page’ => 50, ‘orderby’ => ‘rand’ ); Because of the nature of the site, people could possibly require more posts (there would be a total of 250-300 […]

Minimal wordpress load for only `get_option` to work (because ajax…)

In a plugin I use ajax to get_option() which takes much longer than it has to because entire wp gets loaded. How do I set things up so that it (my ajax) loads only what is needed? (get_option())

How to optimize my query filtering out unwanted data?

I use get_posts ($arg); to query the post table. Usually I need only three fields: post_title, ID and post_excerpt. But the data returned are many more, including post_content that is usually huge. I know I can use ‘fields’ => ‘ids’ to get only the ID. But I would like to use ‘fields’ => ‘post_title’ or […]

Optimizing WordPress's styles and scripts

I’m trying to optimize my website, get rid off unwanted scripts and styles. I wanted to ask what is the best way to do so. What is the difference between wp_deregister_script and wp_dequeue_script ? If I want to kick out some scripts and styles only from specific pages, and minify it with w3 total catches, […]

Should I remove transients from the wp_options table?

I have been doing some cleaning up in the database of one of my WordPress installs, and I noticed that the wp_options table was about 2.1mb, and had 1200 rows. I’ve gotten it down to around 800 rows, and 1.2mb. However, there are a bunch of transients. Should I remove these? I know they don’t […]

SuperCache for Custom Templates

I’ve started creating custom templates. For instance, I wanted a news template for posts that are news oriented. So, I made news.php <?php /* * Template Name: News Article * Template Post Type: post, page * Description: News Articles Template */ get_header(); ?> And then changed the s around a bit, customized a few things, […]

Can't move jQuery to footer

Below two methods did not help me. My jQuery is always on the head section. What can be the reason? Method 1: (adding below code to function.php) if (!is_admin()) add_action(“wp_enqueue_scripts”, “my_jquery_enqueue”, 11); function my_jquery_enqueue() { wp_deregister_script(‘jquery’); wp_enqueue_script( ‘jquery’, ‘’,array(),’1.9.0′,true); } this one works when I change ‘jquery’, to some other string as first parameter in […]

Publish a message on facebook after having posted a comment

I would like some advice on how to improve the code I use for allowing people to comment posts. Users can only submit a comment if they are connected with Facebook. I started developping this feature directly in the comments.php template. It works but there is another feature which permit people to publish a message […]

How do I edit the htaccess file to optimize my website?

Hi I have tried to optimize my website for a cpl of days but I cant seem to get it done. This is how my .htaccess looks like: Header unset ETag FileETag None # Hantera och redirecta användare till en gemensam error-sia ErrorDocument 404 /psych/cgi-bin/error/error?404 # BEGIN Compress text files <ifModule mod_deflate.c> <filesMatch “\.(css|js|x?html?|php)$”> […]

How to remove in the wordpress database all posts revisions except the last three?

here is the commonly recommended sql command for removing posts revisions and cleaning up the wp database: DELETE a,b,c FROM `wp_posts` a LEFT JOIN `wp_term_relationships` b ON (a.ID = b.object_id) LEFT JOIN `wp_postmeta` c ON (a.ID = c.post_id) WHERE a.post_type = ‘revision’; how can i modify it to keep let’s say the last 3 revisions […]