Display Full Content Instead of Excerpt

I want to display the full page content rather than the excerpt in my child theme. If I make the changes to the parent,

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?

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?

Share Improve this question edited Mar 24, 2019 at 16:31 corkin asked Mar 24, 2019 at 16:26 corkincorkin 11 bronze badge 3
  • what theme are you using, and what file are you editing? – Michael Commented Mar 24, 2019 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 Commented Mar 24, 2019 at 22:20
  • similar problem for me at wordpress.stackexchange/questions/364907/… – KarmicP Commented Apr 23, 2020 at 22:57
Add a comment  | 

1 Answer 1

Reset to default 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745662146a4638902.html

相关推荐

  • Display Full Content Instead of Excerpt

    I want to display the full page content rather than the excerpt in my child theme. If I make the changes to the parent,

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信