Protect wp-config.php with .htaccess – WordPress Code Snippets

Protect wp-config.php with .htaccess – WordPress Code Snippets

To tighten security of your WordPress blog/website, you should prevent direct access to wp-config.php file. You can prevent this with htaccess. Adding this simple code to your .htaccess file will prevent unauthorized access to your wp-config.php file. # Disable direct access to wp-config.php <files wp-config.php> order allow,deny deny from all </files>

Force Use of www in All URLs And Redirect Traffic With .htaccess

Force Use of www in All URLs And Redirect Traffic With .htaccess

A website can be accessed with http://www.domain.com and http://domain.com. If you visit any of these URLs, you will be sent to the same page but they will have different URLs. The main problem is that Google and other search engines consider it as duplicate content and therefore penalize this domain in the search engine ranking….

Remove WordPress Generator Meta Tag Completely

Remove WordPress Generator Meta Tag Completely

By default WordPress adds generator meta tag in website head section. The WordPress generator meta tag displays your website’s WordPress version for anyone to see. It can be considered a security risk to make your WordPress version visible and public. Because you are providing the hacker with the useful information by telling them which version…

Add link to All Options in Wordpress Admin Settings

Add link to All Options in Wordpress Admin Settings

WordPress have a secret options section that contains all core WordPress settings on one single page. Here’s a quick code snippet to display an “All Options” page to view otherwise hidden data. Just add that code to your theme’s functions.php file and then visit the settings menu in the WordPress admin panel. There you’ll see…

Show All Media Attachments to a Post

Show All Media Attachments to a Post

Prior to WordPress 3.6, we had to run a query to retrieve all media attachments to a specific post. We had to do something like this. // show all WordPress post attachments $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if (…