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

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

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

How to disable permalinks to some custom post content?

When defining a custom post type with register_post_type() an array of arguments is passed. Set the public parameter to ‘false’ to prevent generation of permalinks, as well as other associated actions (search, nav, et al). Using the example from the WP Codex: function codex_custom_init() { $args = array( ‘public’ => false, ‘label’ => ‘Books’ ); … Read more

Apply function only if end of url has /amp/ [closed]

In your example, $_SERVER[‘REQUEST_URI’] would return /category/post-slug/amp/ which is not the same as get_permalink($post->ID) which would return https://example.com/category/post-slug/ There are lots of ways to go about this, but one easy one that comes to mind is… if ( strpos($_SERVER[‘REQUEST_URI’], ‘/amp/’ ) !== false ) { The strpos() PHP function finds the position of 2nd string … Read more

How to flush Global query variables in wordpress?

The problem is in your rewrite rule: add_action( ‘init’, ‘my_add_rewrite_rules’ ); function my_add_rewrite_rules() { add_rewrite_rule(‘^child/([^/]+)/?’,’index.php?post_type=child&post_parent=$post_id’,’top’); } Instead of using the matched value, you’ve used $post_id. Since this isn’t a double quoted string, and there is no $post_id variable, the value of post_parent will be the string literal “$post_id”, but post_parent expects a numeric post ID … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)