How to list page or category links in WordPress

These simple peices of code will allow you to display page or category links in your WordPress theme.

To list pages use the following code:

You can exclude specific pages by changing the above code to the following:

Just replace 1 with the ID of the page and add a coma to list more than one.

To list categories use the following code:

You can exclude specific categories by changing the above code to the following:

Just replace 1 with the ID of the category and add a coma to list more than one.

How to mass change article slug urls in WordPress

This piece of PHP code will mass change your WordPress slug links to default slugs WordPress would normally generate from your article titles.

Open wp-config.php, add the following at the bottom:

Save and upload your new wp-config.php and load your home page only one time. Once the loading is completed, remove the code from your wp-config.php file.

Credits: Clorith @ https://github.com/Clorith/wp-slug-update

How to add custom avatar in WordPress

Gravatar has become really easy to use custom avatars across multiple platforms. What if your users don’t use Gravatar or have an avatar, a default avatar is loaded in it’s space. It is recommended you brand your default avatar to your website.

First, lets make sure you have a custom avatar image ready. If you do not, make one in the dimensions of 64×64.

Second, name your avatar whatever you want, let’s say “custom-avatar.jpg”. It’s entirely up to you to name it what you want.

Thirdly, upload your image to wp-content/themes/your-theme/images/.

Lastly, open wp-content/themes/your-theme/functions.php and add the following:

// Adds a custom default avatar
if ( !function_exists(‘fb_addgravatar’) ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo(‘template_directory’) . ‘/images/custom-avatar.jpg’;
$avatar_defaults[$myavatar] = ‘Your Name’;
return $avatar_defaults;
}
add_filter( ‘avatar_defaults’, ‘fb_addgravatar’ );
}

Note: Replace “custom-avatar.jpg” with whatever you named it. Also replace “Your Name” with a name to describe the image – this is normally your website name.

Now go to Settings —> and click on “Discussion”, you will be able to see the custom avatar you just added. You can now choose the newly added custom avatar as the default avatar shown.

Helpful SQL queries to run in WordPress

Here are a list of great queries to run on your WordPress installation.

Remove all spam comments from the database

DELETE FROM HYv3g_comments WHERE HYv3g_comments.comment_approved = 'spam';

Globally enable comments for all users

UPDATE HYv3g_posts SET comment_status = 'open';

Globally disable comments for all users

UPDATE HYv3g_posts SET comment_status = 'closed';

Globally enable comments for registered users only

UPDATE HYv3g_posts SET comment_status = 'registered_only';

Globally enable/disable comments before a certain date

UPDATE HYv3g_posts SET comment_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

Globally enable pingbacks/trackbacks for all users

UPDATE HYv3g_posts SET ping_status = 'open';

Globally disable pingbacks/trackbacks for all users

UPDATE HYv3g_posts SET ping_status = 'closed';

Globally enable/disable pingbacks/trackbacks before a certain date

UPDATE HYv3g_posts SET ping_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

Globally enable/disable all discussion: comments, pingbacks and trackbacks

UPDATE HYv3g_posts SET comment_status = 'open', ping_status = 'open' WHERE comment_status = 'closed' AND post_status = 'publish';

Globally enable/disable comments, pingbacks and trackbacks before a certain date

UPDATE HYv3g_posts SET comment_status = 'closed', ping_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

FedEx, UPS and USPS Shipment tracking url’s

Have you ever wondered how to go directly to your tracking without having to put a tracking number in every time? These are a few of the more popular shipping company’s. Replace “XYZ1234567890” with your tracking number.

Now all you have to do is bookmark the new link and click it every time you want to check up on your shipping status.

UPS:

http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=XYZ1234567890

FedEx:

http://www.fedex.com/Tracking?action=track&tracknumbers=XYZ1234567890

USPS:

https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=XYZ1234567890

OnTrac:

http://www.ontrac.com/trackingdetail.asp?tracking=XYZ1234567890