搜尋
首頁CMS教程&#&按解決WordPress無法使用the_content()方法輸出內容

下面由WordPress教學欄位來介紹給大家WordPress# 無法使用the_content()方法輸出內容的解決辦法,希望對需要的朋友有幫助!

解決WordPress無法使用the_content()方法輸出內容

在使用WordPress裡在一個頁面裡我使用the_content()方法來輸出目前頁面的內容,但卻顯示為空,而標題,url等都沒有問題

在網路上好像遇到這種情況的人很少只找到了一個說是可能是function裡有函數覆蓋了the_content方法

但我將function方法刪除掉還是不行,然後我將程式碼全部刪除掉只留這句話""

結果還是不行,無奈只能用其他方式解決

解決方案:

使用$post物件裡的屬性「 post_content;?>」

下面是我的page.php裡的所有內容

<?php
/** 内页/单页面
 * @author htl
 * @date 2014-01-28
 */
get_header();
?>
<?php get_sidebar()?>
<div id="neirong">
  <?php   if ( have_posts() ) :?>
    <h1><?php the_title();?></h1>
    <div id="content">       
      <?php 
        the_content()方法无法输出文章内容,通过$post对象里的post_content属性来输出
        //the_content();
        //print_r($post);
        echo $post->post_content;?>
    </div>
    <?php else : ?>
  <?php get_template_part( &#39;404&#39;); ?>
<?php endif; ?>
</div>
<!-- neirong end -->
<?php get_footer(); ?>

以上是解決WordPress無法使用the_content()方法輸出內容的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:cnblogs。如有侵權,請聯絡admin@php.cn刪除
WordPress作為大型網站的CMS有多可擴展?WordPress作為大型網站的CMS有多可擴展?May 12, 2025 am 12:08 AM

WordPressCanHandLeLArgeWebsiteswithCareFulplanningAndOptimization.1)USECACHINGTOREDUCESERVERVERLOAD.2)優化YourDataBaseRegularly.3)actimentAcdNtododistibuteContent.4))

WordPress的定製程度如何?WordPress的定製程度如何?May 11, 2025 am 12:11 AM

WordPress的定制化程度非常高,提供了廣泛的靈活性和可定制性。 1)通過主題和插件生態系統,2)利用RESTAPI進行前端開發,3)深入代碼層面進行修改,用戶可以實現高度個性化的體驗。然而,定制化需要掌握PHP、JavaScript、CSS等技術,且需注意性能優化和插件選擇,以避免潛在的問題。

WordPress作為CMS的核心功能是什麼?WordPress作為CMS的核心功能是什麼?May 10, 2025 am 12:15 AM

WordPressisanexcellentchoiceforaCMSduetoitsuser-friendlyinterface,extensiveecosystem,SEOcapabilities,scalability,andsupportivecommunity.1)Itsintuitivedashboardmakescontentmanagementeasyforallusers.2)Thevastarrayofthemesandpluginsallowsforextensivecus

使用WordPress管理內容有多容易?使用WordPress管理內容有多容易?May 09, 2025 am 12:11 AM

WordPressiser-FrightlyDuetLoitsIntuitiveInterfaceAndcms,whosparateContentFromDesign.itoffersArichTextedextEditorforeasyContentCreationAndialibraryFororRaryFororRory.itsflexeNhangedBancedBynhangedBynHangedBynumereNumerSandeMesandPlugins,elloverSandplugins,elloverOverUseCanimpActpercrance

WordPress如何在業務環境中使用?WordPress如何在業務環境中使用?May 08, 2025 am 12:04 AM

1)ITSUPPORTSE-CommerceWithPluginSlikeWooCommerce,允許ProductManagementAndAndPaymentProcessing.2)ITSERVESASASASACMSACMSACMSMSACMSMSACMSMASTRATATEBLOGS,增強SeoAndEngagement.3)

哪些類型的網站不適合WordPress?哪些類型的網站不適合WordPress?May 07, 2025 am 12:10 AM

WordPressIsnotIdeAlforHigh-TrafficWebsites,customAndCompleXapplications,安全性 - 敏感性plicestions,Real-Timedataprocessing,AndhighlyCustomizeduserInterfaces.forhigh-Trafficsites,USENEENEXT.JSORXOLX.JSORCOSTOMSOLTICTS; forCompleXapplications; forcomplexapplications; forcomplexapplications,optfordjangoorrub

您可以使用WordPress構建博客嗎?您可以使用WordPress構建博客嗎?May 06, 2025 am 12:03 AM

Yes,youcanbuildablogwithWordPress.1)ChoosebetweenWordPress.comforbeginnersorWordPress.orgformorecontrol.2)Selectathemetopersonalizeyourblog'slook.3)Usepluginstoenhancefunctionality,likeSEOandsocialmediaintegration.4)Customizeyourthemewithsimplecodetw

WordPress作為CMS平台的安全程度如何?WordPress作為CMS平台的安全程度如何?May 05, 2025 am 12:01 AM

WordPressCanbeseCureifManagedProperly.1)keepthewordPressCoreUpdatedTopatchVulnerabilities.2)vetandupdatepluginsandthemesfromreputables.3)EnforcestrongpasseTSandusetWordssandusetWordwordwo-factorauthenticaliation.4)

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!