Hi trying this code below to get working, but no look so far.
Idea is simple if page template is page-47.php display <h1>Something</h1>
else <h1>This will show on any other page</h1>
.
<?php if ( is_page_template( 'page-47.php' ) ): ?>
<h1>Something</h1>
<?php else: ?>
<h1>This will show on any other page</h1>
<?php endif ?>
Thank You
Hi trying this code below to get working, but no look so far.
Idea is simple if page template is page-47.php display <h1>Something</h1>
else <h1>This will show on any other page</h1>
.
<?php if ( is_page_template( 'page-47.php' ) ): ?>
<h1>Something</h1>
<?php else: ?>
<h1>This will show on any other page</h1>
<?php endif ?>
Thank You
Share Improve this question edited Feb 11, 2019 at 16:51 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Feb 11, 2019 at 15:10 soliddigitalsoliddigital 1731 gold badge1 silver badge6 bronze badges 11 | Show 6 more comments2 Answers
Reset to default 18is_page_template()
will only tell you if the page is using a custom page template. Meaning a template that was created by adding the Template Name:
comment to the file and selecting it from the Template dropdown, as described here. The function works by checking the post meta for which template was selected.
If you have created a page template using the slug or ID using the method described here, which you appear to have, then the template being used is not stored in meta, so won't be picked up by the is_page_template()
function.
If you want to know the filename of the current template being used, regardless of whether it's a custom template or not, you can use the global $template
variable:
global $template;
if ( basename( $template ) === 'page-47.php' ) {
}
Thanks to Jacob Peattie! This also solved my problem.
add_filter( 'woocommerce_currency_symbol', 'change_currency_symbol', 10, 2 );
function change_currency_symbol( $symbols, $currency ) {
global $template;
if ( basename( $template ) === 'archive-chiptuning.php' && ( 'EUR' === $currency )) {
return '';
}
return $symbols;
}
page-47.php
in directory ? Not in the theme root. If so you need tois_page_template( 'templates/page-47.php' );
– Liam Stewart Commented Feb 11, 2019 at 15:14is_page_template( 'page-47.php' )
. But not working. – soliddigital Commented Feb 11, 2019 at 15:17