Archive for July 8th, 2009

Change Page Orders in WordPress

July 8th, 2009 No comments

Directly copied from WordPress support page:

Pages are usually ordered alphabetically, but you can change the order pages are displayed in by using the order field.

Let’s say you have three pages: Animals, Machines, WordPress.

That is the order they will normally appear in. If you wanted WordPress to appear first, you need to do the following:

1. Click Pages –> Edit on the menu.
2. Find the page WordPress and click the title.
3. Find the Attributes module.
4. Put the number 1 in the text field for Order. This tells WordPress to make this the first page in the list.
5. Click the Update Page button.

Repeat the process for your other pages, but use higher numbers for the Order field: 2, 3, etc. This tells WordPress to make these the second and third items in the list.

If you are using the Pages Widget, you will want to edit the widget, click on the Sort By dropdown, and change it to Page Order. Then click the Done button on the widget options box and finally, click the Save Changes button.

Exec-PHP Plugin for WordPress

July 8th, 2009 No comments

In order to execute PHP code in your wordpress post, you will need a plugin that does that for you. I am using Sören Weber’s Exec-PHP plugin.


To install the Exec-PHP plugin:

  1. Download the Exec-PHP plugin archive and extract the files.
  2. Copy the resulting exec-php directory into /wp-content/plugins/ directory.
  3. Activate the plugin through the “Plugins” menu of WordPress (after a fresh installation only the Administrator is allowed to execute PHP code).
  4. Configure blog and user settings if needed.


With Exec-PHP you can execute PHP code in the excerpt and the content portion of your posts and pages (in the following called articles) as also as in text widgets. To execute code, just type in the PHP code as you usually would, encapsulated in <?php ?> tags.

What if I just want to print out PHP code and don’t execute it?

If you just want to print out code and don’t want to execute it, you have to make sure to convert your code to the correct XHTML representation. To do so you have to escape the following characters: < to &lt;, > to &gt;, and & to &amp;.

Categories: Wordpress Tags: , ,

Image Path Broken after Changing Permalinks in WordPress

July 8th, 2009 No comments

The Problem

It is common to use relative image paths in your wordpress post. If you put the image files in the images folder of the root directory. Then the path to, say, logo.jpg is coded as

<img src="/images/logo.jpg" />

This works until you change your permalinks. Permalinks change the url to reflect a directory stucture in place of the ugly '?page_id=127', thus breaking the path to images folder.

The Hack

Where you have used relative image paths, replace it with

<img src="<?php echo get_option('siteurl'); ?>/images/logo.jpg" />

This uses your specific siteurl as a prefix to the path of the image.

Hope this helps, it is a great hack.