• When I click on an archive the page heading says “Monthly Archives: Month Day”. I want it to say “News Archive: Month Day”. How would I go about doing this

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Unfortunately, no option for that.
    It falls under Personal Customization, and as such is out of our scope: https://docs.oceanwp.org/article/685-support-policy
    Usually, when it comes only to a few lines of code, we are more than eager to help everyone achieve the desired look. However, this is really more than that, and I would kindly advise you to consult a professional on this matter.

    For now, kindly try to add the below code in the functions.php file of your child theme and check.

    function my_title_override() {
    	if ( is_archive() ) {
    		// Daily archive title
    		if ( is_day() ) {
    			$title = sprintf( esc_html__( 'NEWS Daily Archives: %s', 'oceanwp' ), get_the_date() );
    		}
    		// Monthly archive title
    		else if ( is_month() ) {
    			$title = sprintf( esc_html__( 'NEWS Monthly Archives: %s', 'oceanwp' ), get_the_date( esc_html_x( 'F Y', 'Page title monthly archives date format', 'oceanwp' ) ) );
    		}
    		// Yearly archive title
    		elseif ( is_year() ) {
    			$title = sprintf( esc_html__( 'NEWS Yearly Archives: %s', 'oceanwp' ), get_the_date( esc_html_x( 'Y', 'Page title yearly archives date format', 'oceanwp' ) ) );
    		}
    	}
    	
    	$title = $title ? $title : get_the_title();
    	return $title;
    }
    add_filter( 'ocean_title', 'my_title_override' );
    • This reply was modified 5 years, 1 month ago by Abhishek.
    Thread Starter preez

    (@preez)

    It now says “NEWS Monthly Archives”. I just want it to say “News Archives”

    https://aksuda.com/wp3/2021/05/

    Replace the above code with this one and check.

    function my_title_override() {
    	if ( is_archive() ) {
    		// Daily archive title
    		if ( is_day() ) {
    			$title = sprintf( esc_html__( 'NEWS Archives: %s', 'oceanwp' ), get_the_date() );
    		}
    		// Monthly archive title
    		else if ( is_month() ) {
    			$title = sprintf( esc_html__( 'NEWS Archives: %s', 'oceanwp' ), get_the_date( esc_html_x( 'F Y', 'Page title monthly archives date format', 'oceanwp' ) ) );
    		}
    		// Yearly archive title
    		elseif ( is_year() ) {
    			$title = sprintf( esc_html__( 'NEWS Archives: %s', 'oceanwp' ), get_the_date( esc_html_x( 'Y', 'Page title yearly archives date format', 'oceanwp' ) ) );
    		}
    	}
    	
    	$title = $title ? $title : get_the_title();
    	return $title;
    }
    add_filter( 'ocean_title', 'my_title_override' );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Page Title’ is closed to new replies.