Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I've created a wordpress website which dynamically displays one of around 400 thousand products by passing 2 query vars to a WP page which has my custom php template. I'm using WPML to translate my pages and I've enabled the option to keep url vars _brand and _sku. All works fine with this setup (pages displays & status 200 ok header). Language switcher also keeps my query vars.
URL looks like: domain.com/en/products/?_brand=JCB&_sku=01%2F117903
however since i want the url to display like domain.com/en/products/a-brand/a-sku I've added the following rewrite rules to my child's functions.php
function rewrite_products() { //en add_rewrite_rule('^products/([^&]+)/([^&]+)', 'index.php?page_id=93837&_brand=$matches[1]&_sku=$matches[2]', 'top'); //nl add_rewrite_rule('^producten/([^&]+)/([^&]+)', 'index.php?page_id=93871&_brand=$matches[1]&_sku=$matches[2]', 'top'); //fr add_rewrite_rule('^produits/([^&]+)/([^&]+)', 'index.php?page_id=93875&_brand=$matches[1]&_sku=$matches[2]', 'top'); //de add_rewrite_rule('^produkte/([^&]+)/([^&]+)', 'index.php?page_id=93876&_brand=$matches[1]&_sku=$matches[2]', 'top'); //es add_rewrite_rule('^productos/([^&]+)/([^&]+)', 'index.php?page_id=93877&_brand=$matches[1]&_sku=$matches[2]', 'top'); } add_action('init', 'rewrite_products'); function rewrite_product_tags() { add_rewrite_tag('%_brand%', '([^&]+)'); add_rewrite_tag('%_sku%', '([^&]+)'); } add_action('init', 'rewrite_product_tags', 10, 0);
I can now surf to the desired URL and I get the same page with the correct product, however the header now gives a 404 as the status.
WPML's language switcher also discards my query vars and just redirects /products/a-brand/a-sku to, for example, /producten (the translation of /products).
but most importantly, the 404 header status is not allowing me to index my pages which i have dumped in a sitemap (around 2M url's) since google thinks the url's are 404's and doesn't index those. This is in contrast is a huge problem.
I've boiled it down to the following problem:
setting header in template doesn't work. Is my regex wrong? any help is appreciated!
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.