Change landmark header of the posts to post title

I’m using renew stack. I would like to change the static landmark header to the post topic/title of the post. Currently the landmark header is “Announcements” with breadcrumb (see screenshot below)

Ideally I’m hoping to make the word “Announcements” smaller, and the Post Title to show in the landmark header. I would like to remove the breadcrumb as well (see mockup below)

I saw some other posts that you provided _landmark-header.php file, but they don’t apply to my case. I only want to apply the changes to POST, not PAGE, not archive.

If you can give me some directions to start with, that would be great. Thank you!

Hello There,

Thanks for writing in!

Because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

Assuming you have your child theme active and ready, please follow the following steps below:
1.) Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2.) Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/RENEW/_LANDMARK-HEADER.PHP
// -----------------------------------------------------------------------------
// Handles content output of large headers for key pages such as the blog or
// search results.
// =============================================================================

$disable_page_title = get_post_meta( get_the_ID(), '_x_entry_disable_page_title', true );
$breadcrumbs        = x_get_option( 'x_breadcrumb_display' );

?>

<?php if ( ! x_is_blank( 1 ) && ! x_is_blank( 2 ) && ! x_is_blank( 4 ) && ! x_is_blank( 5 ) ) : ?>
  <?php if ( is_page() && $disable_page_title == 'on' ) : ?>

  <?php else : ?>

    <header class="x-header-landmark">
      <div class="x-container max width">
        <div class="x-landmark-breadcrumbs-wrap">
          <div class="x-landmark">

          <?php if ( x_is_shop() || x_is_product() ) : ?>

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

          <?php elseif ( x_is_bbpress() ) : ?>

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

          <?php elseif ( x_is_buddypress() ) : ?>
            <?php if ( x_buddypress_is_component_with_landmark_header() ) : ?>

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

            <?php endif; ?>
          <?php elseif ( is_page() ) : ?>

            <h1 class="h-landmark entry-title"><span><?php the_title(); ?></span></h1>

          <?php elseif ( is_home() ) : ?>
            <?php if ( x_is_portfolio_item() ) : ?>

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

            <?php else : ?>

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

            <?php endif; ?>
          <?php elseif ( is_single() ) : ?>

            <h3 class="h-landmark man"><span><?php echo x_get_option( 'x_renew_blog_title' ); ?></span></h3>
            <h1 class="h-landmark entry-title"><span><?php the_title(); ?></span></h1>
          
          <?php elseif ( is_search() ) : ?>

            <h1 class="h-landmark"><span><?php _e( 'Search Results', '__x__' ); ?></span></h1>

          <?php elseif ( is_category() || x_is_portfolio_category() || x_is_product_category() ) : ?>

            <?php

            $meta  = x_get_taxonomy_meta();
            $title = ( $meta['archive-title'] != '' ) ? $meta['archive-title'] : __( 'Category Archive', '__x__' );

            ?>

            <h1 class="h-landmark"><span><?php echo $title; ?></span></h1>

          <?php elseif ( is_tag() || x_is_portfolio_tag() || x_is_product_tag() ) : ?>

            <?php

            $meta  = x_get_taxonomy_meta();
            $title = ( $meta['archive-title'] != '' ) ? $meta['archive-title'] : __( 'Tag Archive', '__x__' );

            ?>

            <h1 class="h-landmark"><span><?php echo $title ?></span></h1>

          <?php elseif ( is_404() ) : ?>

            <h1 class="h-landmark"><span><?php _e( 'Oops!', '__x__' ); ?></span></h1>

          <?php elseif ( is_year() ) : ?>

            <h1 class="h-landmark"><span><?php _e( 'Post Archive by Year', '__x__' ); ?></span></h1>

          <?php elseif ( is_month() ) : ?>

            <h1 class="h-landmark"><span><?php _e( 'Post Archive by Month', '__x__' ); ?></span></h1>

          <?php elseif ( is_day() ) : ?>

            <h1 class="h-landmark"><span><?php _e( 'Post Archive by Day', '__x__' ); ?></span></h1>

          <?php elseif ( x_is_portfolio() ) : ?>

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

          <?php endif; ?>

          </div>

          <?php if ( $breadcrumbs == '1' ) : ?>
            <?php if ( ! is_front_page() && ! x_is_portfolio() ) : ?>
              <div class="x-breadcrumbs-wrap">
                <?php x_breadcrumbs(); ?>
              </div>
            <?php endif; ?>
          <?php endif; ?>

          <?php if ( x_is_portfolio() ) : ?>
            <div class="x-breadcrumbs-wrap">
              <?php x_portfolio_filters(); ?>
            </div>
          <?php endif; ?>

        </div>
      </div>
    </header>

  <?php endif; ?>
<?php endif; ?>

3.) Save the file named as _landmark-header.php
4.) Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/legacy/cranium/headers/views/renew/

5.) Again Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
6.) Insert the following code into that new file

<?php

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

?>

<header class="entry-header">
  <?php if ( is_single() ) : ?>
    <!-- display no title -->
  <?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>

7.) Save the file named as _content-post-header.php
8.) Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/renew/

You will need to create the folder paths since it does not exist in your child theme yet.

Please let us know how it goes.

1 Like

I do have a child theme. I entered the code and files by following your instruction. It works perfectly. Thank you so much!

I use CSS to hide the breadcrumb. Hope that’s the right way to do it.

.single-post .x-breadcrumbs-wrap {
    display: none;
}

.single-post .x-landmark {
    width: 100%;
    padding-right: 0px;
}

Hi,

Your code is correct. Have a nice day! :slight_smile:

One more question, if I want to display the date of the post, what is the code that I should add to _content-post-header.php? Please see the mockup below. Thanks!

Hi again,

You can show the post meta via Theme Options > Blog > Content and turn on the Post Meta

Hope this helps!

Thanks @Nabeel. Your recommendation works, but it displays more than I need. I modified the _content-post-header.php instead:

<?php

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

?>

<header class="entry-header">
  <?php if ( is_single() ) : ?>
    <!-- display no title -->
    <?php
    $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );
    printf( '<div>Posted On %1$s</div>', $date);
    ?>
 <?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 it is the right way to do it.

Hi again,

Yes your code looks fine just make sure you’ve made changes in the child theme.

Cheers!

Yes. I did. Thank you for the reminder!

You are most welcome. :slight_smile:

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