0

I need some help understanding Wordpress's file structure or the URL structure. Not the Template Hierarchy, I understand that. What i mean is how a websites files are set up according to it's URL.

Example:

Lets say I have a website named Country.com which lists information "About" the country and a map to it.

So Lets say I'm at country.com/usa and on the country page of USA I see a link to obtain information on the about as well as a link to go to a page with a map.

Now here is the question, in regular html and css websites each time you see a forward slash it means it's a new folder. country.com/usa usa being the new folder. Now what would USA be in Wordpress? would it be a post? a page? archive?

So the URL would look like this for the example.

country.com/usa

country.com/china

country.com/france

Then on each of those directories they have their own about page and map page.

So:

country.com/usa/about

country.com/china/about

country.com/france/about

I guess a better way and more straight forward way of asking is what are those directories specifically. What template files would I be using to get /about for each country.

So if china is a page then what would the /about be? another page or post?

I am just confused on the "files or url" structure and how people make 1 page contain 10 different directories like,

http://country.com/france/state/city/about/attractions

really confused as to what all the directories /folder/folder/folder and what files they are using for that. Is it Post, Custom Post Type, Archive, Single? Can someone please elaborate.

1

You probably want to create a Page.

In that Page's edit screen, just below the title, you can see the URL that Page can be found at, something like http://country.com/france/

"france" is the slug of that Page, and is highlighted yellow indicating you can edit it. That way the Page can be called "I Love France" or whatever, but the slug can just be "france" instead of the default, "i-love-france". Technically, it is a "virtual directory".

Where a normal website you setup yourself with folders that you can then put html files into might be considered "folders and files" like on your computer, the technical term for a folder on a server is a "directory", and WordPress simply creates "virtual directories".

Also, like you can setup a folder on your own site, say /france/ and then put index.html into that folder, and access that page then at country.com/france/ or country.com/france/index.html, you can think of this new "france" Page as being an invisible index.html inside of the /france/ directory.

If you then want to create sub-directories inside of the virtual /france/ directory, you can create another Page, and assign the france Page as it's Parent. In the right column of the Page's edit screen is a Page Options box with Parent and a dropdown there. More info WordPress Pages can be found here: http://codex.wordpress.org/Pages

You can do this as much as you want, creating a Page "State" that is a child page of France, and then a Page "city" that is a child page of "State", an "about" Page that is a child of "City", and so on.

I suggest using Pages for two reasons:

  1. Posts cannot have parents, and therefor always have a specific directory setup (defined in your WordPress > Settings > Permalinks area), such as /2015/07/04/the-fourth-of-july or /category-slug/post-name or /just-the-post-name ... there are a lot of others too, but generally that's how those work.
  2. Pages CAN have customized directories like /france/state/city/about/whatever/and-so-on/ because you can nest them using the Parent functionality outlined above. Pages are considered "hierarchical", meaning they can be nested.
  3. While Custom Post Types can be hierarchical, however the Codex warns against this as hierarchical post types were only intended for Pages and can bog down your site's admin area if you get too many. I've seen this happen, after about 300 hierarchical CPTs my site stopped working for new content.

Finally, to answer your last paragraph, Pages use the page.php template in your theme.

Hope that helps!

| improve this answer | |
  • Thanks a lot Nathan that was great info. So if I understand correctly it would be best to make one page.php with various templates and make the pages within Wordpress and assign the specific templates and page parents correct? – Lucas Santos Feb 25 '15 at 7:45
  • Yeah, if you want to use different layouts for different pages, that's where Page Templates come in. codex.wordpress.org/Page_Templates – Nathan Feb 25 '15 at 17:02
  • You can also use conditional statements in one page.php file, neither one is necessarily better - with Templates you manage everything in separate files, with conditionals you can theoretically do it all in one file. I use both depending on the project, codex.wordpress.org/Conditional_Tags – Nathan Feb 25 '15 at 17:03
  • I see, I always use a mix of both depending. Thanks a ton Nathan really appreciate it man! – Lucas Santos Feb 26 '15 at 5:39
0

About how Wordpress generates the HTML code “on-the-fly” or “dynamically” you can see that

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.