求助:WordPress首页About Us板块无法显示完整内容
Hey there! I see you're trying to get your homepage's About Us section to show the full content instead of the truncated excerpt with the MORE button—let's get that sorted out quickly.
You already tracked down the right file (page-template/custom-home-page.php) and the exact code block causing this behavior. The core issue is that the template is using the_excerpt(), which is designed to output a short summary of your content. Here's how to adjust it:
Step 1: Replace the Excerpt Function with Full Content
Look for this line in your code snippet:
<p><?php the_excerpt(); ?></p>
Swap it out with:
<div><?php the_content(); ?></div>
We use a <div> instead of keeping the <p> tag because the_content() can include multiple paragraphs, headings, or other elements that won't render properly inside a single paragraph tag.
Step 2: Remove the MORE Button (Optional but Clean)
Since you no longer need the link to the separate About Us page, you can delete the entire MORE button block to clean up the layout:
<div class="more-btn"> <a href="<?php the_permalink(); ?>"><?php esc_html_e('MORE','vw-one-page'); ?></a> </div>
Updated Full Code Snippet
Here’s what the modified section will look like after your changes:
<?php while ( $query->have_posts() ) : $query->the_post(); ?> <div class="row"> <div class="col-lg-8 col-md-7"> <h3><?php the_title(); ?></h3> <hr> <div><?php the_content(); ?></div> </div> <div class="col-lg-4 col-md-5"> <img src="<?php the_post_thumbnail_url('full'); ?>"/> </div> </div> <?php $i++; endwhile; wp_reset_postdata();?> <?php else : ?> <div class="no-postfound"></div> <?php endif; endif;?> </div> </section>
Quick Tips
- Always back up your files before making edits—this lets you revert easily if something doesn’t look right.
- If the full content has layout or spacing issues after the change, you might need to tweak the CSS for the
.col-lg-8.col-md-7container to match your theme’s existing styles.
内容的提问来源于stack exchange,提问作者user987376746090

