I would like to ask something about Wordpress. For example: When i designing a web page, I want to have a column on homepage that displays an excerpt of the About Page(which is inner page). Is there any coding that makes this work? Any solution? Thank you!
1 Answer
You'll need to create a new loop - outside of your main loop - using get_posts()
and passing the page ID
for the 'About' page and setting post_type
to page
Then, inside your new loop simply call get_the_excerpt()
Update: From my links:
$args = array( 'post_type' => 'page' );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<?php echo get_the_excerpt(); ?>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
Should do the trick. I just made minor edits to the examples in the provided links. It's explained better there than I can but it's best to understand the 'how' and 'why' of this; there are important, basic WP concepts in use.
-
How to do so? Because i don't really know about it. Any code you can show me?– JornesJun 2, 2016 at 8:29