0

I want to display the full page content rather than the excerpt in my child theme.

If I make the changes to the parent, they appear on the site. If changes are made to same exact file in child, they do not appear. I know this is because the parent loads after the child, but I need the child changes to stick.

Here's the code:

<?php if ( $page_id ) : ?>
    <div class="about-content-wrapper tg-column-wrapper clearfix">
        <?php
           $the_query = new WP_Query( 'page_id=' . $page_id );
           while ( $the_query->have_posts() ) :
           $the_query->the_post();
           $title_attribute = the_title_attribute( 'echo=0' );

           if ( has_post_thumbnail() ) {
           ?>
           <?php $thumb_id = get_post_thumbnail_id( get_the_ID() );
           $img_altr = get_post_meta( $thumb_id, 
           '_wp_attachment_image_alt', true );
           $img_alt = ! empty( $img_altr ) ? $img_altr : $title_attribute;
           $post_thumbnail_attr = array(
             'alt'   => esc_attr( $img_alt ),
            ); ?>
            <div class="about-image tg-column-2">
            <?php the_post_thumbnail( 'full', $post_thumbnail_attr ); ?>
            </div>
            <?php } ?>

            <div class="about-content tg-column-2">
            <?php
            $output = '<h2 class="about-title"> <a href="' . 
            get_permalink() . '" title="' . $title_attribute . '" alt ="' . $title_attribute . '">' . get_the_title() . '</a></h2>';

            **$output .= '<div class="about-content"><p>' . 
            get_the_excerpt() . '</p></div>';**

            $output .= '<div class="about-btn"> <a href="' . get_permalink() . '">' . __( 'Read more', 'himalayas' ) . '</a>';

            if ( ! empty( $button_text ) ) {
            $output .= '<a href="' . $button_url . '">' . esc_html( $button_text ) . '<i class="fa ' . $button_icon . '"></i></a>';
                                }
               $output .= '</div>';
               echo $output;
               ?>
            </div>
            <?php
            endwhile;

The part in question is the $output .= '<div class="about-content"><p>' . get_the_excerpt() . '</p></div>'; line.

Changing "get_the_excerpt()" to "get_the_content()" when the change is made in the parent, displays the full page content. However, when the change is made in the child, it's still only displaying the excerpt.

Any ideas?

  • what theme are you using, and what file are you editing? – Michael Mar 24 at 18:43
  • It's the Himalayas theme - bit.ly/2UUGUfU and the file is specific to the theme. It's in the widgets folder and it's called "class-himalayas-about-us-widget.php" – corkin Mar 24 at 22:20
0

General notes:

  • it's not good practice to modify the Parent theme. If the theme gets updated, then your changes will be lost.
  • the Child theme is loaded first. Any missing 'parts' (like a template) are then loaded from the parent theme. So a page.php in your child theme will be used instead of the parent's page.php template.

So, if you change the Child page.php, and make a different change to the Parent page.php, the Parent page.php is never called.

You should always make changes to a Child theme. Even if the parent theme is updated, your Child's code will be used.

If you want things to happen differently in a template, copy the template from the parent, modify things, and then place that file in the Child theme's folder.

  • Hey Rick, sorry if I didn't make it clear in the initial message, but I am modifying a child theme. I just modified the parent to see if it made a difference and it did. I then reverted the parent back to it's original code and tried the changes in the same file in my child theme, but they didn't work. – corkin Mar 24 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.