无需登陆FTP 新建一个wordpress主题文件
- 时间:2020-05-27 19:03:24
- 分类:网络文摘
- 阅读:122 次
对于wordpress主题设计者而言,主题文件的效果测试是必不可少的。而每一个新建的主题文件,都必须通过FTP才能上传到主题文件夹下。现在有一个简单的方法,可以绕过FTP直接在wordpress主题文件夹下新建一个空白的主题PHP文件。之后,在线编辑这个PHP文件就可以测试代码效果了。具体操作如下:
PHP有一个叫做“touch”的命令,通过此命令,用户可以获得创建新的PHP文件的权限。假设你的主题目录为yourthemes,想要新建一个new.php文件,只需将下面的代码添加到当前主题的header.php文件中:
- <?php touch('wp-content/themes/yourthemes/new.php'); ?>
之后,保存header.php文件,会在主题目录下自动生成一个空白的new.php文件,如下图:

现在你可以在new.php中添加任意代码了。最后别忘了删除添加到header.php文件中的那行代码。
注:将wordpress模板代码分成更小的PHP文件,易于编辑和在模板中调用。想要在模板文件中调用新建的new.php文件,可以通过下面的代码:
- <?php get_template_part(' new '); ?>
原文:http://www.quickonlinetips.com/archives/2014/06/wordpress-theme-files-without-ftp
推荐阅读:Find Numbers with Even Number of Digits using the Reduce Functio How to Convert Blogging Leads into Sales 24 Things Your WordPress Form Plugin Can Do Besides Create A Con Blogging and Finance Management: How to Secure Your Financial Fu 9 Easy-to-Use SEO Tips to Boost Your Site’s Visibility Today How to Land Guest Blogging Opportunities in Under an Hour Tips For Creating An Education Blog That Will Attract Followers What Is Data Blending, And What Does It Have To Do With SEO? 7 Elements of a Perfect Social Media Video 9 Simple Strategies to Improve Sales Today
- 评论列表
-
- 添加评论