Codex

Useful SQL hacks on wordpress

1. Delete all unused tags

2. Delete all revisions

3. Change Site URL and home URL

4. Update post GUID

5. Update links in post content

6. Update user password

7. Update user username

8. Assign all posts from author A to B

9. Delete certain Post Meta

10. Export all emails from comments

11. Delete Pingbacks

12. Delete all spam comments

or

13. Disactive all activated […]

By |September 19th, 2014|Codex, Tutorial|

No Follow WP Nav Menu Links

When I am developing a wordpre theme for a customer, he requested to nofollow all the nav menu links.

1) Usually I will encourage my users to use the menu settings to nofollow certain nav menu links, 2)but if you want to automatically nofollow all the links, you’ll have to work out a solution or […]

By |September 15th, 2014|Codex, Tutorial|

Add Custom Fields to Category and other Taxonomies

In the development of ViralNova wordpress theme, I have to add a custom icon image for each category. I’ve tried the Category Images plugin but I want a more simple way so that I can use Font Awesome icons. We know by default Category only have 4 fields: Name, Slug, Parent, Description. If we […]

By |September 7th, 2014|Codex, Tutorial|

Display Post Thumbnail Automatically and Smartly

Display the post thumbnail automatically. This function will retrieve the image url in this order: custom field of "ct_image", featured image, first image url found in the post content, a default image.

By |August 3rd, 2014|Codex, Tutorial|

Cache wp_nav_menu to speed up your wordpress blog

In general your menus cannot be updated frequently so it's a better idea to cache it by setting an expired period. To make this possible, let's welcome Transients API and pre_wp_nav_menu. Long story short, put following codes to your functions.php and you are done.

By |August 1st, 2014|Codex, Tutorial|

Remove LI Elements From Output of wp_nav_menu

You can remove or change the <ul> container that you get by default with wp_nav_menu(codex) through parameters, but you can’t remove the <li> elements that wrap each menu item.

For example, what to do if this is the structure that we want?

This is the solutino how you can actually remove them:

By |July 30th, 2014|Codex, Tutorial|

Display image directly from URL retrieved in comment content

Now and then, you’ll want to enable image in the comment of your wordpress blog. There are many ways to achieve this, like

directly enter a full html code

,

or use a third party plugin (e.g. comment images) to allow readers upload images to the media library.

For the html way, you are really frustrate your readers […]

By |July 26th, 2014|Codex, Tutorial|

Get the URL of the first link found in your wordpress post content

While creating a new clone theme, I need to get the URL of the first link found in the post content. Fortunately, there is a read-to-use snippet in the default Twenty Eleven theme. If you are using Twenty Eleven, then you are all set up, otherwise add following to your functions.php.

Usage:

Be noted that this […]

By |July 22nd, 2014|Codex, Tutorial|

Limit minimal length of comment content in wordpress

Your readers like your article, and you also like to hear what they think of. But in most cases what you want is a descriptive and detailed content in the discussion instead of “Thank you”, “Great article”, etc.

So you probably want to limit the minimal comment length in your wordpress blog. This is what […]

By |July 18th, 2014|Codex, Tutorial|

How to sort posts by Facebook Shares in wordpress

Now and then, you’ll want to sort posts in different ways instead of default “by date” for your wordpress blogs. One of the frequently asked questions is how to sort posts by facebook shares. Apparently this is not a built-in parameter in wordpress core functions (see WP_query) so we are going to create a […]

By |July 13th, 2014|Codex, Tutorial|