if the content does not contain [ ] then the title is echoed. If it doesn't then the title isn't echoed - my content on this page is not built using visual composer - hence I was getting no title. However even with building the page using VC I was still getting no title.
The php function preg_match returns 1 if there are matches, 0 if there are no matches and only returns false if there is an error. As the page uses === to evaluate $is_vc_page being booleanfalse (not just 0) the code will only show a title if preg_match returns an error.
Is this desired behavior? I've already corrected page.php in my child theme - as I need the title regardless of their being shortcodes in the content.
Oxygen Theme - page.php
Hi, I was trying to get the title to display on my pages. In page.php a check is done
$is_vc_page = preg_match("/(\[.*?\])/", $content);presumably checking for shortcode braces '[ ]' in order to establish if the content contains visual composer shortcodes.
The $is_vc_page variable is then used to decide on how the page should be output
<?php if($is_vc_page === false): ?> <div class="col-md-12"> <div class="white-block block-pad"> <h1 class="single-page-title"><?php echo the_title(); ?></h1> <div class="post-content"> <?php the_content(); ?> </div> </div> </div> <?php else: ?> <?php the_content(); ?> <?php endif; ?>if the content does not contain [ ] then the title is echoed. If it doesn't then the title isn't echoed - my content on this page is not built using visual composer - hence I was getting no title. However even with building the page using VC I was still getting no title.
The php function preg_match returns 1 if there are matches, 0 if there are no matches and only returns false if there is an error. As the page uses === to evaluate $is_vc_page being boolean false (not just 0) the code will only show a title if preg_match returns an error.
Is this desired behavior? I've already corrected page.php in my child theme - as I need the title regardless of their being shortcodes in the content.
Just thought I'd point it out :)
Thanks
Hi Scott,
Really nice spot, I haven't took a look at it for a while, so now I understand the real issue.
Here is the quickfix:
Download this file and replace it in this directory (of the theme): /oxygen/ (root)