Blog has Blog Title as H1 instead of Post Title as H1 - PHP Error

Hello,
I had written in previously about this issue…
Two h1’s on Blog Posts - Blog Title and Post Title are Both h1

however, when I tried the final steps suggested by @paul.r, I got the following error:

“Parse error: syntax error, unexpected ‘elseif’ (T_ELSEIF) in /home/supeckse/public_html/wp-content/themes/supecksepticservices/framework/views/renew/_landmark-header.php on line 50”

I copied the original _landmark-header.php file from the parent theme at:
/x/framework/legacy/cranium/headers/views/renew/_landmark-header.php
into this directory in the child theme:
/x-child/framework/views/renew/_landmark-header.php

Then replaced line 50…

<?php echo x_get_option( 'x_renew_blog_title' ); ?>


with the code from @paul.r at the end of this thread.

I since removed the file because it took the site down.

Here’s a screenshot of code replacement - original _landmark-header.php (left) and the new/bad PHP (right).
Can you please tell me what part is incorrect?

Hi Abby,

Thank you for writing in, while that is outside the scope of support, I could point you in the right direction with the understanding that it would ultimately be your responsibility to take it from here.

Please get a new copy of _landmark-header.php from the parent X theme.

On line 43: <?php elseif ( is_home() || is_single() ) : ?>

Please remove the is_home() || condition.

Then just above that line, on empty line 42: please insert this:

<?php elseif ( is_home() ) : ?>
<h2 class="h-landmark"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h2>

Change the h2 tag where you see it fits.



Cheers!

1 Like

OK we’re getting close!
This changed the Blog Title on the actual Blog page to an h2, but left it as an h1 on the posts page. We need to reverse that.

Should I perhaps have KEPT the “is_home” and REMOVED the “is_single” on line 43?

I FIGURED IT OUT!! I FEEL LIKE A GENIUS!! :grin:
So I kept what you did, but changed the h2 back to h1, then changed the h1 to an h2 after “elseif” “is_single”. So now lines 41 through 51 are as follows:

        <h1 class="h-landmark entry-title"><span><?php the_title(); ?></span></h1>
      <?php elseif ( is_home() ) : ?>
      <h1 class="h-landmark"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h1>
      <?php elseif ( is_single() ) : ?>
        <?php if ( x_is_portfolio_item() ) : ?>

          <h1 class="h-landmark"><span><?php echo x_get_parent_portfolio_title(); ?></span></h1>

        <?php else : ?>

          <h2 class="h-landmark"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h2>

I’m sure there might have been a cleaner way of doing it, but this worked! Now my main blog index page has the blog title as an h1, but on my posts page, the Post Title is the only h1. I know people say it doesn’t matter, but I disagree. Especially if the name of your blog doesn’t use great SEO practices.

For others attempting this in the future, You will have to copy this file from the parent theme at:
/x/framework/legacy/cranium/headers/views/renew/_landmark-header.php
to this directory in the child theme:
/x-child/framework/views/renew/_landmark-header.php

Then edit. Please feel free to contact me through https://thehelpfulmarketer.com/ if you have any questions!

1 Like

You’re more than welcome, glad we could help.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.