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?
General notes:
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.