Skip to main content
added 149 characters in body
Source Link

In your loop, you must refer to $wp_query instance:

<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 3);
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) {
    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
        <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
        <?php the_excerpt(__('(more…)'));
    endwhile;
} else {
    echo 'No posts';
}
wp_reset_postdata();
?>

Also, the_excerpt() function takes one optional parameter, which is either Post ID or $post object. To control 'more' link, you use 'excerpt_more' filter.

In your loop, you must refer to $wp_query instance:

<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 3);
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) {
    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
        <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
        <?php the_excerpt(__('(more…)'));
    endwhile;
} else {
    echo 'No posts';
}
wp_reset_postdata();
?>

In your loop, you must refer to $wp_query instance:

<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 3);
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) {
    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
        <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
        <?php the_excerpt();
    endwhile;
} else {
    echo 'No posts';
}
wp_reset_postdata();
?>

Also, the_excerpt() function takes one optional parameter, which is either Post ID or $post object. To control 'more' link, you use 'excerpt_more' filter.

Source Link

In your loop, you must refer to $wp_query instance:

<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 3);
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) {
    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
        <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
        <?php the_excerpt(__('(more…)'));
    endwhile;
} else {
    echo 'No posts';
}
wp_reset_postdata();
?>