How to edit wording of Archive Past Posts widget?

I am using the Archives: Past Post widget and I would like to change the wording in the subtitle. How can I do this?

For example, when I click on June 2017, it shows a title of “Post Archive by Month” and a subtitle of “Below you’ll find a list of all posts from June, 2017”. I want to change the wording in this subtitle.

Specifically, all I want to do is remove the “,” between the month and year so in June’s case, it would read “Below you’ll find a list of all posts from June 2017”

Any help on how to edit this would be appreciated.

Hi There,

Please add the following code under functions.php file locates in your child theme:

add_filter('gettext', 'x_translated_text' );
function x_translated_text($translated) { 
	$translated = str_ireplace("Below you'll find a list of all posts from ", 'Your new text', $translated);
	return $translated; 
}

Hope it helps :slight_smile:

Thank you for the fast reply and help.

This is really close, but not quite what I need. The above changes the text before “June, 2017” but not the “June, 2017”. This is the part I want to change slightly by removing the “,” between “June” and " 2017" so it would read “June 2017”.

The month and year are being programmatically done from someplace and not by myself. I can’t find the script that is generating that “June, 2017”.

Here is a screenshot using the above function in my child theme’s function.php file:

I should add that I am getting the subtitle with “June, 2017” when clicking on the Past Posts June 2017 link in the sidebar.

Thanks,
Monty

Hey Monty,

Thanks for updating in! I assumed that you are using Integrity stack. Because what you are trying to accomplish requires a template customization, we would like 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.

Once 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/INTEGRITY/_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 );
$disable_filters    = get_post_meta( get_the_ID(), '_x_portfolio_disable_filtering', true );

?>

<?php if ( is_home() && x_get_option( 'x_integrity_blog_header_enable' ) == '1' ) : ?>

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo x_get_option( 'x_integrity_blog_title' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo x_get_option( 'x_integrity_blog_subtitle' ); ?></span></p>
  </header>

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

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php _e( 'Search Results', '__x__' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php _e( "Below you'll see everything we could locate for your search of ", '__x__' ); echo '<strong>&ldquo;'; the_search_query(); echo '&rdquo;</strong>'; ?></span></p>
  </header>

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

  <?php

  $meta     = x_get_taxonomy_meta();
  $title    = ( $meta['archive-title']    != '' ) ? $meta['archive-title']    : __( 'Category Archive', '__x__' );
  $subtitle = ( $meta['archive-subtitle'] != '' ) ? $meta['archive-subtitle'] : __( "Below you'll find a list of all posts that have been categorized as ", '__x__' ) . '<strong>&ldquo;' . single_cat_title( '', false ) . '&rdquo;</strong>';

  ?>

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo $title ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo $subtitle ?></span></p>
  </header>

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

  <?php

  $meta     = x_get_taxonomy_meta();
  $title    = ( $meta['archive-title']    != '' ) ? $meta['archive-title']    : __( 'Category Archive', '__x__' );
  $subtitle = ( $meta['archive-subtitle'] != '' ) ? $meta['archive-subtitle'] : __( "Below you'll find a list of all items that have been categorized as ", '__x__' ) . '<strong>&ldquo;' . single_cat_title( '', false ) . '&rdquo;</strong>';

  ?>

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo $title ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo $subtitle ?></span></p>
  </header>

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

  <?php

  $meta     = x_get_taxonomy_meta();
  $title    = ( $meta['archive-title']    != '' ) ? $meta['archive-title']    : __( 'Tag Archive', '__x__' );
  $subtitle = ( $meta['archive-subtitle'] != '' ) ? $meta['archive-subtitle'] : __( "Below you'll find a list of all posts that have been tagged as ", '__x__' ) . '<strong>&ldquo;' . single_tag_title( '', false ) . '&rdquo;</strong>';

  ?>

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo $title; ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo $subtitle; ?></span></p>
  </header>

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

  <?php

  $meta     = x_get_taxonomy_meta();
  $title    = ( $meta['archive-title']    != '' ) ? $meta['archive-title']    : __( 'Tag Archive', '__x__' );
  $subtitle = ( $meta['archive-subtitle'] != '' ) ? $meta['archive-subtitle'] : __( "Below you'll find a list of all items that have been tagged as ", '__x__' ) . '<strong>&ldquo;' . single_tag_title( '', false ) . '&rdquo;</strong>';

  ?>

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo $title; ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo $subtitle; ?></span></p>
  </header>

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

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php _e( 'Oops!', '__x__' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php _e( "You blew up the Internet. ", '__x__' ); ?></span></p>
  </header>

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

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php _e( 'Post Archive by Year', '__x__' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php _e( "Below you'll find a list of all posts from ", '__x__' ); echo '<strong>'; echo get_the_date( 'Y' ); echo '</strong>'; ?></span></p>
  </header>

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

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php _e( 'Post Archive by Month', '__x__' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php _e( "Below you'll find a list of all posts from ", '__x__' ); echo '<strong>'; echo get_the_date( 'F, Y' ); echo '</strong>'; ?></span></p>
  </header>

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

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php _e( 'Post Archive by Day', '__x__' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php _e( "Below you'll find a list of all posts from ", '__x__' ); echo '<strong>'; echo get_the_date( 'F j, Y' ); echo '</strong>'; ?></span></p>
  </header>

<?php elseif ( x_is_portfolio() ) : ?>
  <?php if ( $disable_page_title != 'on' || $disable_filters != 'on' ) : ?>

    <header class="x-header-landmark x-container max width">
      <?php if ( $disable_page_title != 'on' ) : ?>
        <h1 class="h-landmark"><span><?php the_title(); ?></span></h1>
      <?php endif; ?>
      <?php x_portfolio_filters(); ?>
    </header>

  <?php endif; ?>
<?php elseif ( x_is_shop() && x_get_option( 'x_integrity_shop_header_enable' ) == '1' ) : ?>

  <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo x_get_option( 'x_integrity_shop_title' ); ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo x_get_option( 'x_integrity_shop_subtitle' ); ?></span></p>
  </header>

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

    <header class="x-header-landmark x-container max width">
      <h1 class="h-landmark"><span><?php echo x_buddypress_get_the_title(); ?></span></h1>
      <p class="p-landmark-sub"><span><?php echo x_buddypress_get_the_subtitle(); ?></span></p>
    </header>

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

Please find the echo get_the_date( 'F, Y' ); from the code above and remove the comma.

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/integrity/

Please let us know if this works out for you.

Thanks for the detailed instructions. I really appreciate it!

Quick question: I do have a child theme installed and using it but I don’t have the path you mention. All I have is:

wp-content/themes/x-child/framework
wp-content/themes/x-child/framework/views

Do I need to create the exact path above, or can I just put it in one of the 2 directories I listed above? I would just try it but I am having issues uploading to my site at the moment. :frowning:

Also, you are correct in that I am using the Integrity stack.

Thanks again!
Monty

Hi there,

Yes, exactly you need to create the exact folders and copy the file from the path of the parent theme to the path of the Child Theme.

Thank you.

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