{"id":41006,"date":"2014-06-05T16:25:05","date_gmt":"2014-06-05T10:55:05","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=41006"},"modified":"2020-03-20T15:53:37","modified_gmt":"2020-03-20T10:23:37","slug":"wordpress-theme-files-without-ftp","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2014\/06\/wordpress-theme-files-without-ftp\/","title":{"rendered":"How to Add  PHP Files in WordPress Theme without FTP"},"content":{"rendered":"<p>Did you ever want to create new WordPress theme template PHP files, but needed FTP access to the server every time. We experiment a lot with WordPress theme designs and it was very cumbersome to keep logging in via FTP to create new theme files like loop.php \u00a0or nav.php or other PHP files to make the code easier to edit and understand.<\/p>\n<p>There had to be an easier way&#8230;<\/p>\n<h2>New WordPress Template\u00a0Files Without FTP<\/h2>\n<p>PHP has an amazing command called &#8216;touch&#8217; which allows users with rights to create new PHP files. So when you are logged in, simply go to Appearance &gt; Editor &gt; <em>header.php<\/em> and add this single line of code.<\/p>\n<p>Lets say you want to create a new file called<em> shortcodes.php<\/em> in your theme directory called <em>qotstrap.<\/em><\/p>\n<p><code>&lt;?php touch('wp-content\/themes\/qotstrap\/shortcodes.php'); ?&gt;<\/code><\/p>\n<p>Here is what it will look like in the theme editor<\/p>\n<p><img decoding=\"async\" class=\"border alignnone wp-image-50430 size-full\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/create-php-file.png\" alt=\"create php file\" width=\"639\" height=\"202\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/create-php-file.png 639w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/create-php-file-300x95.png 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/create-php-file-150x47.png 150w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/p>\n<p>Save the header.php file and you will find a blank php file created called nav.php.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-50431\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/new-php-file.png\" alt=\"new php file\" width=\"276\" height=\"179\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/new-php-file.png 276w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/new-php-file-150x97.png 150w\" sizes=\"(max-width: 276px) 100vw, 276px\" \/><\/p>\n<p>Now you can add\u00a0whatever code you like to that.<\/p>\n<p><strong><span style=\"color: #ff0000;\">Note<\/span><\/strong>: It is very essential that now you remove the line added to the <strong>header.php<\/strong> and save the file again.<\/p>\n<h2>Get template parts in WordPress<\/h2>\n<p><strong>Super tip<\/strong> &#8211; We prefer breaking down long WordPress template codes into <strong>smaller PHP files<\/strong> which are easier to edit and call in the template, such that they can do instant changes throughout the site.<\/p>\n<p>It is easy to call these theme template files anywhere in the theme template like this. If you want to load a theme file like <em>share_buttons.php<\/em> in <em>single.php<\/em> which displays the posts, simply use the get_template_part code like this in single.php<\/p>\n<p><code>&lt;?php get_template_part(' share_buttons '); ?&gt;<\/code><\/p>\n<p>I am sure WordPress theme designers will find this tip handy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you ever want to create new WordPress theme template PHP files, but needed FTP access to the server every&#8230;<\/p>\n","protected":false},"author":4,"featured_media":50431,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[49,17],"class_list":["post-41006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/41006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=41006"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/41006\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/50431"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=41006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=41006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=41006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}