• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero Blog

NameHero Blog

Web Hosting Tips & Resources From NameHero

  • Hosting
    • Web Hosting
    • VPS Hosting
    • WordPress Hosting
    • WooCommerce Hosting
  • Reseller
  • Enterprise
  • Domains
  • Account
  • Blog Home
  • Categories

How To Get The WordPress Theme Folder Without FTP Access

Bhagwad Park

Published on: June 25, 2018

Categories: WordPress 1

Sometimes you might find yourself working for a client that doesn’t know about FTP. They may have installed WordPress via their cPanel installation script, and don’t know how to create FTP users. Now it’s difficult (but not impossible), to develop and maintain WordPress without FTP. Let’s say you want to create a child theme, but don’t know how to get the WordPress theme folder for the parent without FTP.

Well, this tutorial will show you how!

Step 1: Open the WordPress Theme Editor and Open functions.php

Starting with the recent versions of WordPress, the core functionality is discouraging people from editing theme files directly. So if you want to add a new style rule for example, it’s better to do it from within the theme customizer. However, there are still situations where using the theme editor is useful. And that’s for entering WordPress code.

Open the WordPress dashboard and go to Appearance->Editor on the left-hand side as shown here:

Theme Editor

At first, you’ll get a scary warning telling you not to edit your theme files directly. Click “I Understand” and proceed. On the right-hand size, you’ll see a list of files belonging to your theme. One of them will be labeled “Theme Function” and will have the filename “functions.php” like this:

Add Code to Functions php

Now let’s insert some code.

Step 2: Inserting Code (Safely) into functions.php

The window on the left-hand size might already have some text inside it. In which case, we’re going to add our own code snippet to it.

Warning for Older Themes

There’s a potentially disastrous bomb waiting to go off if you don’t add code to functions.php in a safe manner. Actually, there are many mines that will blow up your site if you trigger them – including making a syntax error. This is one of the big disadvantages of adding code through functions.php. Later on, I’ll show you a safer way of adding code.

At the bottom of functions.php, you might see the following symbol:

?>

Delete it.

This is the closing tag of a PHP script. Older themes tend to have these in functions.php and it’s dangerous, because anything after it – including a single empty space – will cause the site to crash. So get rid of it! We no longer need to explicitly close PHP tags anymore, so there’s no reason to have it.

If the symbol ?> doesn’t exist, just move to the next part – pasting the code.

Copy the following code and paste it into the end of functions.php:

function theme_folder(){
               return get_bloginfo('stylesheet_directory');
}
add_shortcode('theme_folder', 'theme_folder');

Now save your changes.

Step 3: Using the Shortcode to Get the Theme Directory

Once you’ve saved the changes to functions.php, start a new post and paste the following into the editor:

[theme_folder]

like this:

Use the Shortcode

Now just view a preview of the page and you should get a URL that looks like this:

Get the WordPress Theme Folder without FTP Access

The last word in the URL is the directory name of your current theme! In the screenshot above, the name of the folder is “write” – aptly for the “Write” theme. Of course, not all directories will be so obviously linked to their folder names, so the above code is useful to make sure.

Step 4: Delete the Code Afterward

Once you know your theme folder’s name, go to functions.php and delete the code you entered in Step 2. There’s no need to have additional code cluttering up your PHP scripts! Our work is done, and we should try and keep our code pages as clean as possible. Besides, you don’t want anyone else to use the shortcode to get your theme folder name. So it’s a question of security as well.

Ideally, you should get FTP access from your clients. But if that’s not forthcoming, or you don’t want to wait until you get the credentials, this is a good way to get the WordPress theme folder without it!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!

Most Popular Posts

Speed up your site: solving the WordPress slowdown

NameHero’s Recommended WordPress Plugin and Theme Setup (2023)

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • Website Performance
  • Web Hosting
  • Resellers
  • Website Development
  • Website Security
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • Domains
Help & Support
  • NameHero Blog
  • Knowledgebase
  • Announcements
  • Affiliates
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2023 NameHero, LLC. All rights reserved.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA