Answer the question
In order to leave comments, you need to log in
How to display the desired script through a php condition for the desired Wordpress page?
Good afternoon!
I work with wordpress.
There is a task for a specific page (post) with id=25 to connect your script cutom-
scripts.js the theme is crooked and wp_footer( ) is inserted crookedly in the wrong place (not my site).
But you can connect it directly in the footer.php itself (because the scripts are already connected there). Here are just PHP I know quite a bit and do not have enough knowledge of how to correctly write the condition. I bring my code:
<script src="<?php bloginfo('template_url'); ?>/module/jquery/jquery.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/module/formstyler/jquery.formstyler.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/module/rangeslider/ion.rangeSlider.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/module/owl-carousel/owl.carousel.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/module/fancybox/jquery.fancybox.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/module/maskedinput/jquery.mask.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/scripts/main.js"></script>
<?php
$post_id = get_the_ID();
if ($post_id = 25) {
?>
<script src="<?php bloginfo('template_url'); ?>/scripts/custom-scripts.js"></script>
<?php
}
?>
Answer the question
In order to leave comments, you need to log in
if ($post_id == 25) {
, if it doesn't work print $post_id and see if it contains the required id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question