How to display newest comments first in a WordPress post

The easiest way to display new comments first in a WordPress post is to change some discussion settings.

new comments first in wordpress

I have highlighted the discussion settings you need to pay attention to.

  1. Log into your WordPress admin
  2. Under “Settings” click on “Discussion”
  3. Under “Other Comment Settings” check the box in front of “Break comments into pages…”
  4. For the first drop down box select “first” and for the second drop down box select “newer”
  5. Hit save, you’re all done!

Display text or link in WordPress until a certain date (PHP)

If you have some text, or a link, or maybe a calendar event that you want to link to and might expire, you can easily display it and then on a certain date remove that information (actually hide it) using some PHP code. You can do this on any PHP page, but if you’re using wordpress and you want it in a widget you should download a plugin that handles PHP code like the “Executable PHP widget” but many are available.

Here’s the PHP code:

Change the date to the day you want the link or text hidden. It will be using the server date and time. Let’s say you want the link or text to expire on Jan 05, 2020 then you would use this code.

<?php if(strtotime('2012-01-01') > time()): ?>
Put your text or link here
<?php endif; ?>

How to setup free CDN to make your WordPress Blog Faster!

CDN stands for “content delivery network” and the purpose of using one is to improve the overall speed of your site by improving your blog performance by decreasing server load and optimizing your website making things load faster. With a faster loading website it can help you achieve a better search engine ranking as well as make your readers happy because most people want to see what they’re looking for RIGHT NOW!

I’m currently using Speedy Mirror one one of my sites. They used to offer a ton of bandwidth (50 GB) at no charge, but now they offer a free 5GB of bandwidth for free and this month I have about 1GB left. Need more? you can join the paid service. I use this in conjunction with the WordPress plugin W3 Total Cache. Instead of write a tutorial on how to set up the CND with the wordpress caching pluign, just visit freshtutorial.com for step by step instructions and screenshots.

With Speedy Mirror, your content is spontaneously duplicated to our servers, which are based in many different areas around the world. Your users will automatically download from the nearest mirror, so they will experience higher download speeds. Your bandwidth will be precisely calculated and you will pay only for the gigabytes transferred by our network.

Another free option is CloudFlare which is a CDN and I’m now using it for this website. They offer premium paid services as well. Basically all a user has to do is change their name server records and your site should be online even if your server goes offline. You can only modify your name servers settings if you own your own domain name. You will have to switch your name servers to CloudFlare to get their protection and CDN services. Doing a dig or checking whois would reflect CloudFlare’s name servers. I don’t understand why you’d pay for the service yet unless they limit the number of domains you can have in your account. You can see a list of the worldwide servers here, also for sites using Cloudflare it means site loading times should be very quick even if you’re connecting across the world using a VPN. They also have a WordPress plugin.

Cloudflare and W3 Total Cache WordPress Settings

CloudFlare uses a CDN-like infrastructure to deliver the best in performance to your site. The faster page load times will keep your visitors online longer and our caching mechanism will save you CPU and bandwidth resources.

Read about CDN benefits here. And Cloudflare funding: $22 Million +

CDN Server Locations Worldwide International

In the event that your server is unavailable, visitors should still be able to access your site because CloudFlare serves the visitor a page from its cache.

 October 5th Update:

I’ve been using this service for about 10 days now and I’m happy with it. Here are some stats from the control panel. I notice my sites run faster and I have saved some bandwidth.

Cloudflare Stats Free CDN Service

What is Cloudflare? It’s a free CDN! So far 349,899 requests saved by CloudFlare 572,858 total requests. 7.7 GB bandwidth saved by CloudFlare 12.6 GB total bandwidth

Cloudflare CDN Bot and Threat Control Panel

Help prevent hackers and spammers and malicious threats from slamming your site with junk!

How to fix WordPress Updates (FTP Connection Information)

When I upgrade WordPress to a new version (here’s a link to the screenshot) or update WordPress plugins (here’s a link to the screenshot) I’m always asked for my FTP “Connection Information” which gets really annoying. I solved the problem easily, but there are a few other solutions that might work for you that I documented below.

Solution 1: Add FTP Info to wp-config (this worked for me!)

  • FTP into your host.
  • Navigate to your root folder of your domain
  • Edit the wp-config.php file
  • Towards the end of the file (before the ?>) add your FTP info like this (screenshot here):
    /** Lets me update without entering FTP info. */
    define(‘FTP_HOST’, ‘host’);
    define(‘FTP_USER’, ‘user’);
    define(‘FTP_PASS’, ‘pass’);
  • Change host to your FTP hostname. Change user to your FTP Username. Change pass to your FTP Password.
  • Save file, and now it should work.
  • I then physically moved my wp-config.php file up one folder so it can’t be accessed through the web. If you’re worried about wp-config vulnerabilities and wordpress security, then read this codex page to learn about hardening your wordpress installation.

Solution 2: FS_METHOD (this did not work for me unfortunately)

Edit: I already went with Solution 1. But if you want to try this Solution 2, make sure to read ktgeak’s useful comment at the bottom of this post.

Add this into your wp-config.php file towards the end of the file (before the ?>) and then save the file. Then it magically… could… work…

/** Lets me update without entering FTP info. */
define(‘FS_METHOD’, ‘direct’);

I found this solution here but it didn’t work for me – I ran into the problem of files and folders not being able to be created or deleted due to permission issues (Could not delete  /blah/blah/blah/). The easiest way to get around the issue is by turning PHP Safe Mode Off. So I did that but it still didn’t work. The next idea would be to CHMOD all folders and files to 777 but then that’s a real pain to do to plugins and all folders and files for a direct WordPress version upgrade. And I’m hesitant of having everything 777 and lazy to do specific files.

For those that want to know what the FS_METHOD does, here you go (from the editing wp-config wordpress page):

FS_METHOD forces the filesystem method. It should only be “direct”, “ssh”, “ftpext”, or “ftpsockets”. Generally, You should only change this if you are experiencing update problems, If you change it, and it doesnt help change it back/remove it, Under most circumstances, setting it to ‘ftpsockets’ will work if the automatically chosen method does not.

  • (Primary Preference) “direct” forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate.
  • (Secondary Preference) “ssh2” is to force the usage of the SSH PHP Extension if installed
  • (3rd Preference) “ftpext” is to force the usage of the FTP PHP Extension for FTP Access, and finally
  • (4th Preference) “ftpsockets” utilises the PHP Sockets Class for FTP Access.

Solution 2: Run wordpress as same user as apache user (I did not try this)

Seems very possible after speaking with my web hosting company! Read about this solution here.

Many hosting companies will run your apache instance using your user account, and all of your files will be owned by the same account. In those cases, you will probably not have the issue described here.

If your hosting company is running apache as a system user, and your files are owned by your own account, your only option may be to enter your FTP credentials here and allow WordPress to use FTP.

I spoke with my hosting company and they suggested I should consider using them to upgrade blogs for me using their scripts instead of doing this via an automatic update via the admin page. I’ll probably end up doing this since it’s a managed hosting solution anyway and then I won’t have to worry about updates.

They then said if I still want to do the upgrade from the admin page, they  can change the ownership of all the files from the current one to the apache user. But adding new plugins manually or installing new domains and wordpress installs, sounds like a lot of work to have them change the file ownership all the time.

If you have a better solution to this problem please post it in the comments section.