keaglez

Hi! I'm Jeffri Hong, also known as keaglez, a 20 years old geek who love the web and comic.

Some useful tips for WordPress custom post type and taxonomy

Posted on Programming, Wordpress and tagged with ,

Custom post type is one of the most powerful WordPress feature. It allows us to create just any content we need, combined with custom taxonomy, the possibility is just endless. WordPress have allowed to have custom post type and taxonomy for some while, but with WordPress 3, everything is far more easier. We have register_post_type and register_taxonomy created specifically for this purpose.

While this two combined to be a wonderful addition for your WordPress blog, there is still a lot of things that is not yet documented. Here is a few useful tips I collected when working with custom post type and taxonomy.

Read more…

Blog redesign

Posted on Designing, Programming, Wordpress and tagged with , , , , ,

Welcome to my new redesigned blog! It’s been a year and a half since the last time I changed the design. I have always wanted to change it, but I just always don’t have enough time. :) I know I’m not that good enough in designing, but at least, this is the best design I ever made until now!

The idea behind this design is, to make a simple, usable layout and still looks beautiful. There is a lot of tutorial on the web that helped me when making this. I try to make the website small in size, so you’ll able to load it fast enough. There is also a cool trick on the background, which still make the markup small without much wrapping div over div to accomplish the effect. I also realize the importance on social networking nowadays, so I add links to some of my account. :)

Read more…

Checking the current post type with is_singular function

Posted on Programming, Wordpress

The WordPress 3 introduce a new feature that let us easily make our own custom post type. This is really a cool feature that give more possibility to customize the WordPress powered website. However, I find that the documentation is not complete yet.

In the recent problem I got, it requires me to check the current post type, something like is_single for post and is_page for page. Luckily enough, the is_singular is now changed to accept a parameter, and that is post type. :)

In current codex page, it still not updated. However, now we can use this to check whether we are on our post type page or not.

if ( is_singular(“my-post-type”) )
// whatever you want to do here

Great!

If the_content stop working after upgrading to WordPress 3

Posted on Wordpress

Well, this is one common problem happened after upgrading to WordPress 3. After upgrading to WordPress 3, the content is not displayed. This is happened likely because you don’t call the_post before you call the_content.

In previous version of WordPress, when we are on single/page, this worked fine. Some themes didn’t go into the WordPress loop on single/page template, since WordPress already know which page/post to show. This also make sense, single/page only have 1 post to be displayed, so we shouldn’t need to get into the WordPress loop. However, in the recent version, the_content failed to display anything if you don’t call the_post beforehand.

I’m not sure which one should be the correct behavior. In codex, it’s pretty clear that we still need to get into WordPress loop, even though we are in single/page template. However, in theory, calling the_post before calling any other function that supposed to be in the loop should fix it.

Just a quick note, I don’t want to forgot this trivial stuff when I got this problem again in future. :)

Frustating WordPress Database Error

Posted on Wordpress and tagged with ,

Have you ever got this error? While this happens, you must make sure you have configured your wp-config.php. Check for these line:

define(‘DB_NAME’, ‘putyourdbnamehere’);

/** MySQL database username */
define(‘DB_USER’, ‘usernamehere’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘yourpasswordhere’);

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

Above is taken from wp-config-sample.php file. As long as you have configured the DB_NAME, DB_USER and DB_PASSWORD correctly, you should be fine. Some host might use a different DB_HOST, but mostly worked fine with localhost.

Well, if it does configured correctly and there still the same error happen, you might need to check the wp_options table.

Open the wp_options table using PHPMyAdmin or other similar software. Find the value siteurl in column option_name, if you see the option_value get a blank value like below:

Then you are probably on right track. Edit this row and insert your domain full URL in the option_value. Save.

Hopefully the error will go away. I don’t know why this could happen, but it did happen in one of my client website… :) It’s indeed frustating to look for this error, since WordPress didn’t give any specific information about it.

If you found another cause of this error, please share.

Proudly powered by Wordpress