Category Archives: WordPress

WordPress Archive Page for Custom Post Type

Get archive link for a specific post type: <a href="<?php echo get_post_type_archive_link( ‘books’ ); ?>">Books List</a><a href="<?php echo get_post_type_archive_link( ‘books’ ); ?>">Books List</a> Set archive permalink for a custom post type when registering the cpt: $args = array( … ‘has_archive’ => ‘books-list’, // can be "true" or the permalink string );   register_post_type( ‘books’ , […]

WordPress Migrate from HTTP to HTTPS

Simple guide to migrate WordPress from HTTP to HTTPS: 1) Install free SSL certificate with Lets Encrypt 2) Enable SSL HTTP/2 for best performances 3) Change WordPress Site URL Open the Dashboard->Settings->General. Change http://www.yoursite.com to https://www.yoursite.com 4) Replace all http:// to https:// in post contents Use these MySQL queries to do the hard work: UPDATE […]

Disable WordPress Embeds

Some users have reported that the json URLs are sometimes indexed by Google: http://www.site.com/wp-json/oembed/1.0/embed?url=http%3A…http://www.site.com/wp-json/oembed/1.0/embed?url=http%3A… To disable WordPress embeds you can use this plugin: https://wordpress.org/plugins/disable-embeds/ You can also remove these references in HTML head: <link rel=’https://api.w.org/’ href=’http://example.com/wp-json/’ /> <link rel="alternate" type="application/json+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=…" /> <link rel="alternate" type="text/xml+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=…" /><link rel=’https://api.w.org/’ href=’http://example.com/wp-json/’ /> <link rel="alternate" type="application/json+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=…" /> […]

Constant WP_POST_REVISIONS already defined

If you get this warning message in your WordPress website: Notice: Constant WP_POST_REVISIONS already defined in /var/www/wordpress/wp-config.php on line 95Notice: Constant WP_POST_REVISIONS already defined in /var/www/wordpress/wp-config.php on line 95 Make sure that the definition of the constant WP_POST_REVISIONS is after WordPress has been loaded. Edit wp-config.php and make sure WP_POST_REVISIONS is defined after require_once(ABSPATH . […]

Update a WordPress Plugin via UNIX Shell Prompt

Need to update a WordPress plugin via UNIX shell prompt? Open the /wp-content/plugins directory, example: cd /var/www/wpsite.com/htdocs/wp-content/pluginscd /var/www/wpsite.com/htdocs/wp-content/plugins Let’s say you need to update WordPress SEO plugin, type: rm -rf wordpress-seo wget https://downloads.wordpress.org/plugin/wordpress-seo.3.9.zip unzip *.zip rm -f *.ziprm -rf wordpress-seo wget https://downloads.wordpress.org/plugin/wordpress-seo.3.9.zip unzip *.zip rm -f *.zip That’s all!

Update WordPress from UNIX Shell Prompt

Need to update WordPress from UNIX shell prompt? Set the current directory to the root folder of WordPress installation: cd /var/www/wpsite.com/htdocs/cd /var/www/wpsite.com/htdocs/ Now type these commands to update WordPress to latest version: rm -rf wp-admin rm -rf wp-includes mv wp-config.php wp-config.bak rm -f *.php mv wp-config.bak wp-config.php wget -O latest.tar.gz https://wordpress.org/latest.tar.gz gunzip latest.tar.gz tar xf […]

Disable the Plugin and Theme Editor on WordPress

To disable only the file editor (but allow for plugins and themes installation), simply add this line to your wp-config.php file (above the “ABSPATH” otherwise it won’t work): define(‘DISALLOW_FILE_EDIT’, true);define(‘DISALLOW_FILE_EDIT’, true);

Disable Plugin and Theme Update and Installation on WordPress

Prevents users from being able to update or install plugins and themes, plus removes the “Editor” menu so users can’t edit files. Add this line to your wp-config.php file (above the “ABSPATH” otherwise it won’t work): define(‘DISALLOW_FILE_MODS’, true);define(‘DISALLOW_FILE_MODS’, true); To allow plugins and themes installation and updates but disable only the file editor, use this: […]

Change Siteurl with MySQL Queries on WordPress

To change the siteurl of your WordPress site, use these SQL queries: UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’; UPDATE wp_posts SET guid = replace(guid, ‘http://www.oldsite.com’, ‘http://www.newsite.com’); UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.oldsite.com’, ‘http://www.newsite.com’); UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’);UPDATE wp_options SET option_value […]

Disable XML-RPC in WordPress

WordPress uses XML-RPC to remotely execute functions. For example, Jetpack and the WordPress mobile application use xmlrpc to remotely manage a WP site. However, also attackers try to exploit the xmlrpc.php file for bruteforce attacks. These attacks result in exhaustion of system resources causing services like PHP-FPM and MySQL to be unresponsive and as a […]