admin管理员组文章数量:1429633
I am new to wordpress and I have made custom code as below. Where I can place this custom code in wordpress. I want to redirect the website domain and all pages but wanted to display popup message for few seconds (3 to 5) and automatically redirect to any external URL.
<script type="text/javascript">
function Redirect()
{
window.location="";
}
$(window).on('load',function(){
$('#myModal').modal('show');
setTimeout('Redirect()', 5000);
});
</script>
<div class="container">
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Beaumondevillas are part of Natural Retreats</h4>
</div>
<div class="modal-body">
<p>We are redirecting the Natural Retreats Palm Spring Page</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
I am new to wordpress and I have made custom code as below. Where I can place this custom code in wordpress. I want to redirect the website domain and all pages but wanted to display popup message for few seconds (3 to 5) and automatically redirect to any external URL.
<script type="text/javascript">
function Redirect()
{
window.location="https://example";
}
$(window).on('load',function(){
$('#myModal').modal('show');
setTimeout('Redirect()', 5000);
});
</script>
<div class="container">
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Beaumondevillas are part of Natural Retreats</h4>
</div>
<div class="modal-body">
<p>We are redirecting the Natural Retreats Palm Spring Page</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Share
Improve this question
edited May 15, 2019 at 20:37
Nisarg
asked May 15, 2019 at 20:02
NisargNisarg
1013 bronze badges
1 Answer
Reset to default 1"Where" somewhat depends on the theme you're using. Here's couple examples,
If you have a custom made theme, then you can put the code in any appropriate place. For example
header.php
(after<head>
) orfooter.php
.If you have child theme, then you can copy a suitable
template_part
file from the parent theme to the child dir and add the code to that file.Add the code with a action/filter hook. For example
wp_footer
(although the button might look a bit silly with this one) or append it tothe_content
.If you don't need to show the redirected domains content, you could create custom page template and page to which you first redirect all users with
template_redirect
(ortemplate_include
) to serve as a landing page. Then include your custom redirect modal on that page.
版权声明:本文标题:functions - Redirect website domain (including all pages) to external URL after Popup message (few seconds) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745489726a2660549.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论