In what way is it not working?
Thread Starter
m1000
(@m1000)
It doesn’t display script in footer, when I remove
if ( is_page_template( 'frontpage1.php' ) ) { }
condition then it works but I want to didplay it on frontpage1.php temmplate.
-
This reply was modified 9 years, 8 months ago by
m1000.
-
This reply was modified 9 years, 8 months ago by
m1000.
Use the plugin “show current template” to double check on what is the “master” template for rendering a page.
Thread Starter
m1000
(@m1000)
It’s showing Template: frontpage1.php on toolbal
Thread Starter
m1000
(@m1000)
BTW I use this code in functions.php
OK, just checking for low hanging fruit. And that template is in the top level of the theme directory?
OH, just re-looked at your code. Remove the function def from the conditional — it should be like this:
function enqueue_xxxx() {
if ( is_page_template( 'frontpage1.php' ) ) {
?>
<script type="text/javascript">
.....
</script>
<?php
}
}
add_action('wp_footer', 'enqueue_xxxx');
Thread Starter
m1000
(@m1000)
Thanks but I used this code and it’s not working
function enqueue_xxxx() {
if ( is_page_template( 'frontpage1.php' ) ) { ?>
CODE
<?php
}
}
add_action('wp_footer', 'enqueue_xxxx');
-
This reply was modified 9 years, 8 months ago by
m1000.
Let’s try an experiment:
function enqueue_xxxx() {
echo '<!-- Page template is ' . get_template_slug() . ' -->';
}
add_action('wp_footer', 'enqueue_xxxx');
run that and see what appears in the page source
Thread Starter
m1000
(@m1000)
It’s breaking the page
This code also breaking the page after Page template is
function enqueue_xxxx() { ?>
Page template is <?php echo get_template_slug();
}
add_action('wp_footer', 'enqueue_xxxx');
-
This reply was modified 9 years, 8 months ago by
m1000.