Redirect product page to course page

Home Forums Legacy Support Support queries How-to & Troubleshooting Redirect product page to course page

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #131823
    lu1szarz4
    Spectator
    Hi, 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. Thanks
    #131867
    H.K. Latiyan
    Participant
    Hi, 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.
    #131954
    lu1szarz4
    Spectator
    Can this be achieved through a 301 redirect, somehow? Thanks
    #132096
    H.K. Latiyan
    Participant
    Hi, 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.
    #132192
    lu1szarz4
    Spectator
    I 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/
    #132272
    H.K. Latiyan
    Participant
    Hi, 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.  
    #132513
    lu1szarz4
    Spectator
    Hi, 1) This is not likely to happen, but it happens redirect them to homepage 2) Redirect them to one of the courses. Whichever.
    #132543
    H.K. Latiyan
    Participant
    Hi, 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();   }   }
    #278430
    prateekgupta2009
    Participant
    In 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...
    #278563
    Diana
    Participant
    If you will pass anything here: http://prntscr.com/tqxde7 The page will be redirected to that page if course is not connected
    #278602
    prateekgupta2009
    Participant
    When 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....
    #278945
    Diana
    Participant
    Please do not post on someone else topic Closing this topic
Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Redirect product page to course page’ is closed to new replies.