Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在帖子顶部显示摘录_Php_Wordpress - Fatal编程技术网

Php 在帖子顶部显示摘录

Php 在帖子顶部显示摘录,php,wordpress,Php,Wordpress,我有一个用于多个测验的js测验模板,我希望每个测验都能显示文章的摘录。我试着在模板顶部添加,但只显示了带有“点击阅读更多”按钮的摘录。有没有一种方法可以在没有“阅读更多”且内容在后面的情况下将文章的摘录称为文章摘要 法语测验 尝试使用获取摘录(): $my_excerpt = get_the_excerpt(); echo $my_excerpt; 还有更多关于这个的 编辑: 这与所有post函数一样,需要在循环中调用: <?php global $more; $more = -1;

我有一个用于多个测验的js测验模板,我希望每个测验都能显示文章的摘录。我试着在模板顶部添加
,但只显示了带有“点击阅读更多”按钮的摘录。有没有一种方法可以在没有“阅读更多”且内容在后面的情况下将文章的摘录称为文章摘要


法语测验

尝试使用
获取摘录()

$my_excerpt = get_the_excerpt();
echo $my_excerpt;
还有更多关于这个的

编辑:

这与所有post函数一样,需要在循环中调用:

<?php
global $more; $more = -1; // suppress the more tag
if ( have_posts() ) {
    while ( have_posts() ) {
        $my_excerpt = get_the_excerpt();
        echo $my_excerpt;
    } // end while
} // end if
?>


get\u必须在循环中使用摘录()。他把它称为循环外。这好多了,谢谢,但它仍然有“点击阅读”按钮。你可以自定义该文本:但它在循环外工作,就在我最初使用的地方“@lkl-它可能在第一篇文章中工作,但我看不出它在超过一篇文章中如何工作。无论哪种方式,在处理POST时,在循环中做事情都是一种很好的做法=)
<?php
global $more; $more = -1; // suppress the more tag
if ( have_posts() ) {
    while ( have_posts() ) {
        $my_excerpt = get_the_excerpt();
        echo $my_excerpt;
    } // end while
} // end if
?>