Php 获取文章列表中的Wordpress摘录
我正在构建一个自定义的WordPress小部件/插件,以在永久链接中返回文章的标题和摘录。我已经快到了,但我正努力让这段摘录展现出来。这是我目前的代码:Php 获取文章列表中的Wordpress摘录,php,wordpress,Php,Wordpress,我正在构建一个自定义的WordPress小部件/插件,以在永久链接中返回文章的标题和摘录。我已经快到了,但我正努力让这段摘录展现出来。这是我目前的代码: <?php $args = array( 'numberposts' => '5' ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_posts as $recent ){ $categories = get_the_category($
<?php
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
$categories = get_the_category($recent["ID"]);
$excerpt = apply_filters('get_the_excerpt', $recent->post_excerpt);
echo '<a class="m-item diet-and-nutrition" href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" > <div class="pix"></div><div class="eyebrow"> <b>' . $categories[0]->name . '</b> / '. $recent["post_date"].'</div> <figure>' . get_the_post_thumbnail($recent["ID"], 'full') . '<figcaption class="center"> <span> <h4>'. $recent["post_title"].'</h4> </span> <span> <p>'. $excerpt .'</p> </span> </figcaption> </figure> </a>';
}
?>
这是一个数组,因此:
$recent->post_excerpt
应该是:
$recent['post_excerpt'];