在不同页面中更改h1

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:

  1. Don't use inline styles. That is bad form. Assign a CSS class, and add the CSS to your stylesheet.
  2. Format your code. Never-ending blocks of code are impossible to read, diagnose, and troubleshoot.
  3. Doing it this way is going to lead to a big mess of conditional if statements. is_page is only going to handle one override for you at a time, AND it's brittle - if the page slug / title changes, this function will no longer pick it up. I'd strongly recommend getting and using something like Advanced Custom Fields and allow setting the "Display Title" that way. It'd be much easier to code, maintain, etc.

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>