I have the code below in my page.php
template but the div isn’t showing up on the woocommerce
pages. Rather, nothing shows up. What is wrong with the code?
<?php if ( is_page('woocommerce') ): ?>
<div id="banner">
<h2>New shop is open!</h2>
</div>
<?php endif; ?>
3
Answers
Use like this.
This function
is_page
in wordpress is a function to check if a page exist withid
,title
,slug
, array. You can read more aboutis_page()
function in the wordpress documentationWith your code, you are checking a page with slug or title = “woocommerce” exists or not. Were do you check if this page exists in your wordpress?
Maybe there is another template, like page-woocommerce.php kicking in before page.php. See: https://developer.wordpress.org/themes/basics/template-files/.