Trouble removing h1 from Pro child theme

I created a previous thread on this issue: Pro Child Theme - Support - Themeco Forum

Basically, I followed the instructions and mimicked the Pro’s path/directory structure, replacing the original file, which looked like this:
<?php

// =============================================================================
// VIEWS/RENEW/_CONTENT-POST-HEADER.PHP
// -----------------------------------------------------------------------------
// Standard <header> output for various posts.
// =============================================================================

?>

<header class="entry-header">
  <?php if ( is_single() ) : ?>
  <h1 class="entry-title"><?php the_title(); ?></h1>
  <?php else : ?>
  <h2 class="entry-title">
    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_title(); ?></a>
  </h2>
  <?php x_renew_entry_meta(); ?>
</header>

with this:

<?php

// =============================================================================

// VIEWS/RENEW/_CONTENT-POST-HEADER.PHP

// -----------------------------------------------------------------------------

// Standard <header> output for various posts.

// =============================================================================

?>

<header class="entry-header">

  <h2 class="entry-title">

    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_title(); ?></a>

  </h2>

</header>

This is in our dev environment. All it has done is remove the name of the author and date, and not the title of the blog posts.

I’d appreciate some more detailed instruction on this.

Hello @agorder,

Thanks for writing in! What you did only remove the h1 yet it still displays the post title. The post meta or the author and date of the post can be enabled/disabled in Pro > Theme Options > Blog > Content. If you only wish to remove the <h1> for SEO purposes, you might have missed the setting in Pro > Theme Options > Headers > Logo > Hidden <h1> so please enable it.

If nothing is helping, please clarify a little further as to what you really want to do with the <h1> or just the post title.

Best Regards.

What we’d like to do is only keep the top h1 title (with the background), and not have the bottom one. This is for SEO purposes, there should only be one h1 in the document. I don’t think this can be done from Theme Options, and even “hiding” it is unacceptable since it is still part of the document and is only hidden with CSS.

Yes, using the PHP code above, the post title was still displayed and the author was removed instead, that was not my intention. I wanted to jettison the extra title.

I might’ve realized my mistake. I also removed <?php x_renew_entry_meta(); ?>, which I assume outputs the post metadata (author and date). So if I leave that in, but get rid of the rest, might it work?

I’m worried about fiddling with the control flow statement. Will this affect other pages, or is it limited to blog posts? I only want this to work on single blog posts.

Hello @agorder,

Modifying the template will only affect the blog posts. Your single blog post may not have a post title if you remove it. Please provide us the URL of what you are working on so that we can check the page structure.

Thanks.

For example, this blog post. We’d like to have only one h1 for the title, not 2. You’ll notice the title is displayed twice.

Hello @agorder,

Thanks for the link. Now, I see what you mean. You will have to modify your template by adding this as the content:

<?php

// =============================================================================
// VIEWS/RENEW/_CONTENT-POST-HEADER.PHP
// -----------------------------------------------------------------------------
// Standard <header> output for various posts.
// =============================================================================

?>

<header class="entry-header">
  <?php if ( is_single() ) : ?>
    <?php // display nothing ?>
  <?php else : ?>
  <h2 class="entry-title">
    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_title(); ?></a>
  </h2>
  <?php endif; ?>
  <?php x_renew_entry_meta(); ?>
</header>

Hope this helps.

That did it. Thank you.

Hello @agorder,

Gald to know that things are well for you. Please feel free to reach us if you have any queries regarding our theme and theme settings.

Thanks

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