[英]Wordpress page redirect to home
My page is redirecting to home due to some problem in code. 由于代码中的某些问题,我的页面正在重定向到首页。
I have three links: 我有三个链接:
The first link is working fine while other two links are redirecting to home 第一个链接工作正常,而其他两个链接重定向到首页
Initially it was fine as there was a term and condition page after the link as in code below. 最初很好,因为链接后有一个条款页面,如下面的代码所示。
<?php if(isset($_POST['accepted']) && $_POST['agree'] == 1) { while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; ?> <?php } else { ?> <?php query_posts('page_id=182'); while ( have_posts() ) : the_post(); ?> <h2>Terms & Conditions</h1> <?php the_content(); ?> <form method="post" action=""> <p><input type="checkbox" value="1" id="agree" name="agree" style="margin-right: 10px;" /><label for="agree">I accept terms and conditions.</label><input type="submit" id="accepted" name="accepted" class="btn btn-primary btn-sm" value="View Tips" title="Check the box to proceed" style="margin-left:10px;"/></p> </form> <?php endwhile; ?> <?php } ?>
Now I have modified code to bypass intermediate page "Terms and condition" and problem started. 现在,我修改了代码以绕过中间页“条款和条件”,问题开始了。
<?php if(isset($_POST['accepted']) && $_POST['agree'] == 1) { while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; ?> <?php } else { ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> <?php } ?>
But this only work for first link other links are redirecting to home page 但这仅适用于第一个链接,其他链接正在重定向到主页
Sorry guys, I got the issue.....:-) 抱歉,我遇到了问题..... :-)
In header.php there was a code that was forcing it to redirect to home for certain condition. 在header.php中,有一个代码强制其在某些情况下重定向到主页。
if(is_page(array(220,221)) && !is_user_logged_in()){ wp_redirect(home_url()); exit(); }
I simply removed it and the things are working fine. 我只是将其删除,一切正常。
Thanks a Lot 非常感谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.