Webmaster Blog

Webmaster Resources

Wordpress: Importing large XML files

In order to import large XML files you will have to make sure that the following settings are set in your PHP.ini :

max_filesize_upload Default : 2M -> increase to 10M or larger

That is the size that is displayed close to the submit button on the import page.
In order to get it running you should also check your settings for memory_limit and max_execution_time. The first one is the setting for the amount of memory a script can handle and the latter one the maximum time for transactions. If the import takes too long it might get cancel’d because of that setting.

Wordpress: Count SQL Queries

For a developer loading speed is a crucial factor, therefore it is necessary to check how many SQL queries are needed to build a page.

To do that in Wordpress add this code anywhere in your template and it will show the queries that are needed until that specific part. If you want to know how many queries are needed for loading the full page then put the code in the footer.php

<? php echo get_num_queries(); ?>

You are able to use it several times inside your template, so insert it anywhere as many times as required.That’s great for locating potential “troublemakers”

Source:Playworkplay.com

Wordpress: WP-Postratings “get_highest_rated”

get_highest_rated is defined at postrating-stats.php and is responsible for displaying the content as well.

Wordpress: Default Post

If you should come in the situation that you always need the same post over and over again, e.g. if you use wordpress as a CMS then I have a useful trick for you.

We have to edit the function “the_editor“, which is defined at general-template.php!

Open the file and find the function; now inside the function find

textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s

Straight after the %s add the text that is supposed to be your default post. If it’s a complex string you can safe the text in a variable e.g. $defaulttext = “here goes my php code”; and simply add $defaulttext after %s, but before the closing textarea tag!

Wordpress: Default Custom Fields

If you should ever come in the situation that you want a default custom field on your “write page” you should first of all create a draft with your default custom fields.
After that go to your phpMyAdmin interface and lookup the postid.
Once you got the postid simply goto “wp_postmeta” and find the postid of that draft. Change the id to zero.
VoilĂ  now you will have the custom field you defined in the draft at your write page. This is especially handy if you always need the same custom field because you can simply copy it.

Multilingual Wordpress

To realize a multilingual wordpress you have to follow the following steps:

1. Check if your theme is ready for localization.

To do that open for example comments.php in your theme folder and search for text that is currently displayed on your blog e.g.”Leave a comment”.

If it’s looking similar to

 " _e("Leave a comment", "mytheme");  "

then your theme should already be ready for localization.

2. Optional

If not then you will have to wrap the “_e” around every text passage in your theme. Replace mytheme with your theme’s name. Also don’t forget that this has to be inside a php statement!

You can do it like that:

<?php  _e("Text", "mytheme"); ?>

Inside a function:

'__('Text', "mytheme")'

e.g.

 comments_rss_link(__('Subscribe to the comments via RSS Feed', "mytheme"));

3. Add load_theme_textdomain to your functions.php

This is a very important step because it will load the text via gettext before sending out the headers. Add the following at the very first line of your functions.php inside your theme folder: (if you don’t have one create a functions.php!)

 <?php load_theme_textdomain('mytheme'); ?>
Page 1 of 212»