如何通过传递字符串php.I打印wordpress中的内容我写了下面的代码,但它打印所有的内容,包括image.I希望它只打印特定文本。如何通过传递字符串来打印wordpress php中的内容
<?php
$content = get_the_content('Read more');
print $content;
?>
如何通过传递字符串php.I打印wordpress中的内容我写了下面的代码,但它打印所有的内容,包括image.I希望它只打印特定文本。如何通过传递字符串来打印wordpress php中的内容
<?php
$content = get_the_content('Read more');
print $content;
?>
这取决于你是否是在循环 - 如果你是你的代码应该工作 - 看到更多在这里:https://codex.wordpress.org/The_Loop
但是,如果你是外循环,并想通过在后ID作为参数,则可以参考这篇文章作为一切有很好的解释:https://wordpress.stackexchange.com/questions/51741/get-post-content-from-outside-the-loop
$page_id = 302;
$page_object = get_page($page_id);
echo $page_object->post_content;
使用the_excerpt仅显示有更多
含量少<?php $short_desc= get_the_excerpt();
echo substr($short_desc,0,200);?>
我想先打印200个字的内容,我该怎么办。 – Mohit
<?php $ short_desc = get_the_excerpt(); echo substr($ short_desc,0,200);?> –
请使用此命令打印200字内容... –
https://codex.wordpress.org/Function_Reference/get_the_content – C2486