I have a WP site, every page have a heading H1 acting as a title, right that code change the that heading like this, if the page is services post that if not post the title of tha page, but I want to post a different title that the name of the page.
Here is my code:
<h1 style="background: #000;
color:#FFF;
margin-bottom:10px;
padding:8px 12px;
box-sizing:border-box;
text-transform: uppercase;
font-size: 16px;">
<?php if (is_page('services')) {
?>SERVICES<?php
} else {
the_title();
}
?>
</h1>
So many things to address:
Lastly - using what little you've given us, here is your code restructured into a much more readable, usable, and functioning solution:
<?php
// Load the title into a variable for simpler manipulation / logic
$title = get_the_title();
// If the page is the 'services' slug page, set the title
if ( is_page('services') ) {
$title = 'Services';
}
// other conditions can go here, if you like
if ( is_page('contact' ) {
$title = 'Contact Us';
}
?>
<h1 class="page-title"><?php echo $title; ?></h1>