I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics

I would stick to make the url https://example.com/life/life-article/?special=1 I would create a php function that: retrives all posts and stores them in a variable; make a loop to loop all the posts and check if they are “life” posts; inside the same loop, if they are “life” posts, change their slug to …whatever/?special=1; and then … Read more

How to allow WordPress to recognize a custom URL segment after a product URL and use a custom template?

Looks like all I needed to do was put the template_include filter inside of the init action. Source: https://stackoverflow.com/a/50037707/5749974 add_action( ‘init’, function () { $product_base = ltrim( get_option( ‘woocommerce_permalinks’ )[ ‘product_base’ ], “https://wordpress.stackexchange.com/” ); add_rewrite_rule( “{$product_base}/([^/]+)/test”, ‘index.php?product=$matches[1]&test=1’, ‘top’ ); add_filter( ‘template_include’, function( $template ) { if ( get_query_var( ‘test’ ) ) { $template = get_stylesheet_directory() … Read more