本篇文章给大家带来了关于WordPress的相关知识,其中主要跟大家聊一聊WordPress怎么通过header给页面发送原生HTTP头,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。
在PHP中,我们可以用 header 函数来发送原生 HTTP 头,但在WordPress中怎么发送HTTP 头呢?
方法一:自己写代码
将下面的代码放到当前主题的functions.php中即可:
/** * 在用户登陆的情况下,给前台所有页面添加不缓存的 Cache-Control 头 */ function ludou_http_headers() { // 判断用户是否登陆,并且是在非后台(前台)页面 if(is_user_logged_in() && !is_admin()) { // php的header函数发送HTTP 头 header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); } } /* WordPress hook * 第一个参数值 wp 是action动作名称,文档:https://codex.wordpress.org/Plugin_API/Action_Reference/wp * 第二个参数值 ludou_http_headers 是上面的函数名称,自己取名 */ add_action( 'wp', 'ludou_http_headers' );
方法二:用插件
HTTP Headers:https://wordpress.org/plugins/http-headers/
HTTP headers to improve web site security:https://wordpress.org/plugins/http-security/
推荐学习:《WordPress教程》
以上是聊聊WordPress怎么通过header给页面发送原生HTTP头的详细内容。更多信息请关注PHP中文网其他相关文章!

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

1)ITSUPPORTSE-CommerceWithPluginSlikeWooCommerce,允许ProductManagementAndAndPaymentProcessing.2)ITSERVESASASASACMSACMSACMSMSACMSMSACMSMASTRATATEBLOGS,增强SeoAndEngagement.3)

WordPressIsnotIdeAlforHigh-TrafficWebsites,customandCompleXapplications,Security-SensitiveApplications,Real-TimedataProcessing,AndhighlyCustomizedUserInterfaces.forhigh-Trafficsites,USENENEXT.JSORXOLCT.JSORXORX.JSORCUSTOMSOMOLTICTS; forCompleXapplications; forcomplexapplications; optfordjangoorrub

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

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

WordPressCanbuildVariousTypesofwebsites:1)个人博客,EasyTosetUpWithTheMesandPlugins.2)BusinessWebsites,使用drag-and-dropbuilders.3)e-commercePlatforms,forwoocommerceforsemcommerceforseameamseamelesssites.4)communitySites.4)conduction.4)使用bbudicatipration

WordPressisapowerfulCMSwithsignificantadvantagesandchallenges.1)It'suser-friendlyandcustomizable,idealforbeginners.2)Itsflexibilitycanleadtositebloatandsecurityissuesifnotmanagedproperly.3)Regularupdatesandperformanceoptimizationsarenecessarytomainta

WordPressExcccelineaseeandaDaptability,MakeitiTidealForBeginnersandsMallTomedium-SizedBusinesses.1)siseofuse:wordpressisuser-Frylyly.2)安全:drupalleadswithstrongsecurityfeatures.3)性能:performance:performance formation:ghandoffersefersefersefersefersefersefersefersexcellentperformanceeduetonodeutonode.jsorscor.jssor.jjsy.jjsy.jjsy.4)4)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具