Permalink in local wordpress

It could happen that wordpress in localhost doesn’t see textual permalink, such as the article name, or the like, and see only ”simple” permalink with a final suffix such as ?p=123.

The problem is an apache problem. To fix it, you have to:

  • modifying the apache config file, with a name such as apache2.conf or another name, depending of your S.O., by adding something like
<Directory /var/www/your-wordpress-path/>
	Options Indexes FollowSymLinks
	AllowOverride all
	Require all granted
</Directory>
  • then you have to do these bash commands  (in a terminal):
sudo a2enmod rewrite
sudo systemctl restart apache2
  • then you have to put in your (root wordpress) folder an .htaccess file with a content like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /your-wordpress-path/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-wordpress-path/index.php [L]
</IfModule>

your-wordpress-path is the path following http://localhost, so don't have to write http://localhost

At this point you should be able to set a textual permalink, after setting it, save it, and try.

mysql multiple tables rename

To rename many mysql/mariadb tables with a same prefix, you can uso this script (in a terminal)

mysql -u root -p -N -e " SELECT CONCAT('RENAME TABLE \', table_name, '\ TO \', REPLACE(table_name, 'oldprefix_', 'newprefix_'), '\;') FROM information_schema.tables WHERE table_schema = 'your-database' AND table_name LIKE 'oldprefix_%'; " > renamed.sql 

In this way will created the file renamed.sql (same tables, with different names), that you then can use to replace your database, with

mysql -u root -p yourdatabase < renamed.sql

If you have a wordpress database you have also to check options and meta tables, removing oldprefixes, with:

UPDATE oldprefix_options
SET option_name = REPLACE(option_name, 'oldprefix_', 'newprefix_')
WHERE option_name LIKE 'oldprefix\_%';

and

UPDATE abc_usermeta
SET meta_key = REPLACE(meta_key, 'oldprefix_', 'newprefix_')
WHERE meta_key LIKE 'oldprefix\_%';

And finally, you could check if there are any oldprefix, in options with

SELECT option_name FROM newprefix_options WHERE option_name LIKE 'oldprefix\_%';

same for meta:

SELECT meta_key FROM newprefix_usermeta WHERE meta_key LIKE 'oldprefix\_%';

Connecting a wordpress category to a facebook page

IFTT is a good app, but with a free plan you can connect only one wordpress category to one facebook page.

There are many plugins and many web services, such as Zapier, or Activepieces, that can connect wordpress with a facebook page, but if you have a free wordpress plan (with an address like yourdomain.wordpress.com) you can install plugins only upgrading your plan.