• I have made several child themes in the past, but I pretty much only modified CSS. With a current project I want to change a line in home.php. With CSS I could import the original style.css and make only the changes I wanted. I can’t figure out how to do this with PHP.

    For example, I have home.php that looks like this:

    <?php get_header(); ?>
    
    <?php if ( is_home() && get_option('aggregate_featured') == 'on' ) get_template_part('includes/featured','home'); ?>
    
    <?php if ( is_active_sidebar( 'homepage-recentfrom-area-1' ) || is_active_sidebar( 'homepage-recentfrom-area-2' ) || is_active_sidebar( 'homepage-recentfrom-area-3' ) ) { ?>
    	<?php if ( is_active_sidebar( 'homepage-recentfrom-area-1' ) && !dynamic_sidebar('homepage-recentfrom-area-1') ) : ?>
    	<?php endif; ?>
    
    	<?php if ( is_active_sidebar( 'homepage-recentfrom-area-2' ) && !dynamic_sidebar('homepage-recentfrom-area-2') ) : ?>
    	<?php endif; ?>
    
    	<?php if ( is_active_sidebar( 'homepage-recentfrom-area-3' ) && !dynamic_sidebar('homepage-recentfrom-area-3') ) : ?>
    	<?php endif; ?>
    
    	<div class="clear"></div>
    <?php } ?>
    
    <div id="main-content" class="clearfix">
    	<div id="left-area">
    		<h4 class="main-title"><?php esc_html_e('Most Recent Articles','Aggregate'); ?></h4>
    		<div id="entries">
    			<?php get_template_part('includes/entry','home'); ?>
    		</div> <!-- end #entries -->
    	</div> <!-- end #left-area -->
    
    	<?php if ( is_active_sidebar( 'homepage-sidebar' ) ) { ?>
    		<div id="sidebar">
    			<?php if ( !dynamic_sidebar('homepage-sidebar') ) : ?>
    			<?php endif; ?>
    		</div> <!-- #sidebar -->
    	<?php } else { ?>
    		<?php get_sidebar(); ?>
    	<?php } ?>
    <?php get_footer(); ?>

    I simply want to change:

    <h4 class="main-title"><?php esc_html_e('Most Recent Articles','Aggregate'); ?></h4>

    with:

    <h4 class="main-title"><?php esc_html_e('News and Announcements','Aggregate'); ?></h4>

    I understand that I can simply copy and paste the entire home.php file to my child theme directory and make the simple change, but that overrides the ENTIRE home.php in the original theme. If a theme update comes along and makes changes, I wouldn’t know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • That’s right, you wouldn’t. The assumption is that if you are creating a child theme, you know what you want and it’s not what’s in the parent theme file.

    Can’t have your cake and eat it, I’m afraid.

    Cheers

    PAe

    As the theme is using translations with esc_html_e( you could just create a theme .po and .mo language file.

    filename : row number

    #: home.php:20
    msgid "Most Recent Articles"
    msgstr "News and Announcements"

    HTH

    David

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Child Themes – PHP Question’ is closed to new replies.