WordPress函数:get_extended(获取扩展信息)

Description【描述】

Get extended entry info ( <!–more–> ).【获取扩展的文章信息(<!–more–> )】

There should not be any space after the second dash and before the word ‘more’. There can be text or space(s) after the word ‘more’, but won’t be referenced.【在第二个破折号的后面和单词”more”的前面都不能有空格。在“more“ 的后面可以包含文字或空格,但是不会被引用。】

The returned array has ‘main’ and ‘extended’ keys. Main has the text before the <code><!–more–></code> . The ‘extended’ key has the content after the <code><!–more–></code> comment.【返回的数组包含”main“和 ”extended“这两个值。”main“包含<code><!–more–></code> 前面的文本,”extended“包含<code><!–more–></code>评论后面的内容】

Usage【用法】

&lt;?php <a href="https://www.wpdaxue.com/tag/get_extended" title="查看与【get_extended】相关的文章" target="_blank" rel="noopener">get_extended</a>( $post_content ) ?&gt;

Parameters【参数】

$post_content
(string) (required) Post content. 【(必要的)文字内容。】

Default: None【默认:None】

Return Values【返回的值】

(array)
Post before (‘main’) and after (‘extended’).

Examples【例子】

Displaying small excerpts from latest posts.【显示最新文章的小摘要】

If you want to display the latest posts on your WordPress blog, but only the content which comes before the <!–more–> tag, you can use this:【如果你希望在你的WordPress博客中显示最新文章,但只显示<!–more–>标签前面的内容,你可以使用下面的代码】

&lt;ul&gt;
global $post;
$args = array( 'numberposts' =&gt; 5);
$myposts = get_posts( $args );
foreach( $myposts as $post ) :	setup_postdata($post);  
$content_arr = get_extended(get_the_content()); ?&gt;
    &lt;li&gt;
       &lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
       &lt;/br&gt;
       &lt;?php echo $content_arr['main'];  //Display the part before the more tag  ?&gt;   
    &lt;/li&gt;
&lt;?php endforeach; ?&gt;
&lt;/ul&gt;

Note: $content_arr[‘extended’] contains the contents after the more tag.【注意:$content_arr[‘extended’] 包含more标签后面的内容】

Change Log【更新记录】

Since: 1.0.0

Source File【源文件】

get_extended() is located in wp-includes/post.php.【get_extended() 在 wp-includes/post.php 中】

参考资料:http://codex.wordpress.org/Function_Reference/get_extended

来源:

https://www.wpdaxue.com/wordpress-function-get_extended.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32322.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?