How to change custom post type, blog post and page permalink by template?

modify post works different than modify page than modify custom post type permalink. Here is how to modify all of them within your template code only and give the whole page a custom url structure. modify custom post type permalink add_action( ‘init’, ‘rewriteCustomPostUrls’ ); function rewriteUrls() { global $wp_rewrite; $version = ‘/product/%product%/version/%version%’; $wp_rewrite->add_rewrite_tag( “%product%”, ‘([^/]+)’, … Read more

Links in post content don’t work on home page

Automatic post excerpts are trimmed to a specific character length, which means it’s possible for HTML tags to be broken. You could end up with an open tag not being closed, for example. To avoid this WordPress strips HTML tags from the content before trimming it for use as an excerpt. The are other reasons … Read more

post permalinks with dot in url don’t resolve to correct page template

I wound up using the index_template filter to load the right template when the CPT single page is being incorrectly redirected to the index and $_SERVER[‘REQUEST_URI’] contains the slug of the CPT. Like so: add_filter(‘index_template’, ‘wpse300393_resolve_cpts_with_dots_in_name’); function wpse300393_resolve_cpts_with_dots_in_name($templates=””){ if( strpos($_SERVER[‘REQUEST_URI’], ‘artwork’) !== false ){ $templates = locate_template( ‘single-artwork.php’ ); } elseif( strpos($_SERVER[‘REQUEST_URI’], ‘artist’) !== false … Read more

Add or Create Custom Structure Tags to Permalink

Here is a random example from one of my slides. Note: tag supposes to be in your type permastruct. random itself will need to be added to public query vars, but let this be a homework, and analyzed somehow. add_rewrite_tag( ‘%random%’, ‘(.+)’, ‘random=’ ); add_filter( ‘available_permalink_structure_tags’, function ( array $tags ) : array { $tags[‘random’] … Read more

LAMP WordPress Permalinks 404 error

Though there are many possibilities like enable Apache web server with the mod_rewrite or check permissions to allow WordPress to write to the .htaccess file. It will be helpful for you, if you go through this for more details. https://codex.wordpress.org/Using_Permalinks

How to filter a custom post type by custom taxonomy without 404

When you want to use a taxonomy inside a custom post type URL hierarchy, you have to register it BEFORE the custom post type. Otherwise it won’t work properly. here is a short example: function so305901_register_taxonomies() { $args = [ //your settings ]; register_taxonomy( ‘taxonomy_slug’, [‘custom_post_type_slug’], $args ); } add_action( ‘init’, ‘so305901_register_taxonomies’ ); function so305901_register_custom_post_types() … Read more

WordPress not generating .htaccess but tells me that (Permalink structure updated.)

Try adding the following to a manually generated .htaccess file # BEGIN WordPress <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 WordPress Without knowing more about the version of WordPress used & the setup of your web-server that’s the ebst … Read more