如何通過傳遞字符串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