在我的索引中。php页面,我使用了此代码,但它没有显示说明,即:我的文章的100个字符?不建议将get\\u the\\u content()替换为$post->post\\u content,我知道这是可行的。但需要正确的输出,保持get\\u the\\u content()。让我知道为了获得输出,我还应该在代码中更改哪些内容。
<?php
$args = array(\'posts_per_page\'=>3,
\'orderby\'=>\'rand\',
\'post_type\'=>\'post\'
);
$post_data = get_posts($args);
foreach($post_data as $post){
echo \'<a href="\'.get_the_permalink().\'">\'.get_the_title().\'</a><br>\';
$post_data = substr(strip_tags(get_the_content()),0,100).\'...\';
echo $post_data."<br>";
}
?>