Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Redirect product page to course page
- This topic has 11 replies, 4 voices, and was last updated 4 years, 3 months ago by Diana.
Viewing 12 posts - 1 through 12 (of 12 total)
-
AuthorPosts
-
October 10, 2017 at 4:32 pm #131823lu1szarz4SpectatorHi, how can I redirect all product pages to their correspondent course pages?? Having in mind that they both have the same ending slug. For example this: http://leexonline.a.wetopi.com/product/how-to-write-effectively/ should redirect to http://leexonline.a.wetopi.com/course/how-to-write-effectively/ Also, http://leexonline.a.wetopi.com/shop should go to http://leexonline.a.wetopi.com/all-courses I don't want the Woocommerce product pages or shop to be shown anywhere. ThanksOctober 11, 2017 at 5:02 am #131867H.K. LatiyanParticipantHi, Sorry this is not available, we redirect the user to product page if they click on the take this course button but vice versa is not available. On the product page the course link is shown so users can click on it to go to the course page. But if the user opens the product page then we do not redirect them to the course page.October 11, 2017 at 9:45 am #131954lu1szarz4SpectatorCan this be achieved through a 301 redirect, somehow? ThanksOctober 12, 2017 at 5:28 am #132096H.K. LatiyanParticipantHi, The button to go to the course page is already there. Do you want that the user should be redirected to the course page automatically when the product page is accessed. Do you not want to show the product page at all.October 12, 2017 at 11:56 am #132192lu1szarz4SpectatorI want the user to be redirected to the course page automatically when the product page is accessed. Some kind of 301 redirection in the htaccess. Having in mind that all the urls have a pattern. See here the similarities: http://leexonline.a.wetopi.com/product/how-to-write-effectively/ http://leexonline.a.wetopi.com/course/how-to-write-effectively/October 13, 2017 at 5:15 am #132272H.K. LatiyanParticipantHi, I can provide you a code to redirect the user to the course page when she tries to open the product page. But first I have some questions: 1) If a product has no course connected to it then what should happen in that case. 2) If a product is connected to more than 1 course then what should happen in that case.October 15, 2017 at 1:10 pm #132513lu1szarz4SpectatorHi, 1) This is not likely to happen, but it happens redirect them to homepage 2) Redirect them to one of the courses. Whichever.October 16, 2017 at 5:18 am #132543H.K. LatiyanParticipantHi, Add the below code in your wplms-customizer.php file present in your wp-admin->plugins->editor->select wplms customizer plugin->wplms-customizer.php file: add_action('template_redirect','custom_redirect_to_course_page_from_product_page',1); function custom_redirect_to_course_page_from_product_page(){ global $post; if( get_post_type($post->ID) != 'product' || !is_singular('product') ){ return; } $courses = get_post_meta($post->ID,'vibe_courses',true); if( !empty($courses) && is_array($courses) ){ foreach ($courses as $course_id) { wp_redirect( get_permalink($course_id) ); exit(); } }else{ wp_redirect( home_url() ); exit(); } }July 29, 2020 at 12:27 pm #278430prateekgupta2009ParticipantIn context to above what if there is no course connected to Product then what will be the changes in above code in that case if i want to redirect to product page and if course is connected then to course page...July 30, 2020 at 4:36 am #278563DianaParticipantIf you will pass anything here: http://prntscr.com/tqxde7 The page will be redirected to that page if course is not connectedJuly 30, 2020 at 5:53 am #278602prateekgupta2009ParticipantWhen i add the code on my site when i click on Take My Course Button on Course Page then it doesn't add it to cart... it just keep redirecting to course page... It works on Cart Page but then Course Page Take My Course button doesn't work....July 31, 2020 at 6:14 am #278945DianaParticipantPlease do not post on someone else topic Closing this topic
-
AuthorPosts
Viewing 12 posts - 1 through 12 (of 12 total)
- The topic ‘Redirect product page to course page’ is closed to new replies.