Rewrite URL Parameter And Force ‘Pretty’ Permalink

You could force the redirect this way by checking for the get_var query value: add_action(‘init’,’my_redirect_check’); function my_redirect_check() { if (isset($_GET[‘my_var’])) { if ($_GET[‘my_var’] != ”) { if ($_SERVER[“HTTPS”]) {$location = ‘https://’;} else {$location = ‘http://’;} $location .= $_SERVER[‘SERVER_NAME’]; $location .= strtok($_SERVER[‘REQUEST_URI’],’?’); $location = trailingslashit($location); $location .= $_GET[‘my_var’]; $location = trailingslashit($location); wp_redirect($location); exit; } } } … Read more

WordPress Permalinks on Mac OSX Server 5 (El Capitan)

I’d check a few things Apache2 logs open a terminal Check error logs at tail -f /var/log/apache2/error_log Check access logs at tail -f /var/log/apache2/access_log WordPress Check .htaccess has correct rules for basic setup enable wp debugging to see if you can log further errors when the redirect happens this is how you enable WP logging … Read more

Add a Custom Permalink option in the Permalink Admin Screen?

To hook your custom plugin settings into the Permalink settings, use the following: add_action(‘admin_init’, ‘wpse_237141_custom_permalink_section’); function wpse_237141_custom_permalink_section() { add_settings_section( ‘your_custom_id’, // ID ‘Your Plugin Settings’, // Section title ‘your_callback’, // Callback for your function ‘permalink’ // Location (Settings > Permalinks) ); } You’ll need to fill in the blanks to display your own custom functions, … Read more

get_permalink executes link without https

this may be called as a bug in get_permalink, but it may not be. I had the same case, and when I tried to echo site_url(); I get the https://… But once I updated the options for siteurl and home to have https get_option( ‘siteurl’ ); get_option( ‘home’ ); get_permalink worked fine. I noticed that … Read more

.htaccess – Redirect duplicated post ended in ‘-number/’ to the same url without the -number/

You’re close. Add the following to your .htaccess file in between the <IfModule mod_rewrite.c> tags that were created by WordPress: RewriteCond %{HTTP_HOST} RewriteRule ^(.+)-[0-9]+/$ /$1 [R=301] Your .htaccess should looks like the following if it hasn’t been modified by another plugin: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond … Read more

Rewrite URL for results of a custom WP_Query

You could try using the add_rewrite_endpoint function, which would actually let you avoid any htaccess modification (unless you need $_GET). Example: function add_custom_rewrite_ep() { add_rewrite_endpoint(‘cata’, EP_PAGES); add_rewrite_endpoint(‘catb’, EP_PAGES); add_rewrite_endpoint(‘catc’, EP_PAGES); } add_action( ‘init’, ‘add_custom_rewrite_ep’ ); Make sure you flush your rewrite rules. So then, if your URL is /questions/cata/foo/catb/bar/catc/more/, you can access the values with … Read more

Permalinks Messed up

After hours of searching and reading, This is how I solved the Problem. Step 1: Create a .htaccess file in the root folder and put this code there. # BEGIN <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END Step 2: … Read more

Permalink problem

It turns out it was a server issue after all. Adding junk text to the .htaccess file should produce an error but it didn’t, indicating the .htaccess file wasn’t being read at all – https://docs.bolt.cm/3.4/howto/making-sure-htaccess-works I had another look on the hosting console and there was an option to “Sync” the .htaccess file. This fixed … Read more