0

This may seem like a noob question but I think I have entered the wordpress world from the "wrong side".

I have made an custom template where I added for example home.php, about.php and the pages I want locally. Then I use filezilla to upload them and then I created the same pages on wp-admin and chose the corresponding file.php as a template to this. So I make changed locally and upload it instead of doing it on wp-admin. This is for me natural but I want to be able to make it th other way around since my goal in the end is that make this theme available for others to use and then I of course want it as simple as possible and fully usable/editable from the wp-admin.

Also, in the current state nothing happens if i edit the wp-admin contact-page for example on my sites contact-page, it still is a copy of my contact.php.

4
  • in your contact.php do you have the template tag the_content() ?
    – Ben Casey
    Commented Mar 8, 2017 at 20:54
  • @BenCasey No! Didnt know about it but tried it now, so basically I just copy the code from contact.php to contact page and have the the_content in contact.php. But then again - why do I then need the .php-files? Is there some merit to keep both with the same code? Hmm I guess what Im really wondering is there any reason for me to keep both sides? the .php locally and the pages in wp-admin and have them working together like this or should I only use one of them seperately?
    – emcolsson
    Commented Mar 8, 2017 at 21:23
  • 1
    I think you are going about this in a very awkward way. Perhaps you should setup an installation of WordPress locally, and have a look through the default themes, have a look at how they create content and read through the docs on Template Hierarchy
    – Ben Casey
    Commented Mar 8, 2017 at 21:27
  • Yeah I think I am... i do have wp locallybut I will do and read up on that. Thanks
    – emcolsson
    Commented Mar 8, 2017 at 21:35

1 Answer 1

0

I would suggest that you activate a default theme, such as Twenty Seventeen, to see how it works. You do need .php files to make WordPress work, but these are generally either "theme" files (which basically control the look and feel of the site) or "plugin" files (which add or change functionality, like contact forms). In most cases, your theme has more than one PHP file, but also in most cases, you do not need a separate PHP file for every Page on your site.

In a very basic, barebones WordPress theme, you would have style.css, index.php, header.php and footer.php. Header and footer would contain things like navigation, Index would have a call to the_content, and style.css would control the CSS styling of everything. You then create Posts and Pages (and additional post types if you wish) and manage all the content of those pages in wp-admin. The content gets wrapped between your header and footer and any other common code included in the theme, such as breadcrumbs and sidebars.

Hope that helps explain some of the basic concepts you have bypassed. In essence, your PHP files should be in themes and plugins and are used for the look and functionality of your site, and everything else - all the paragraphs, images, text lists and so forth - should be edited in wp-admin. This all gets saved to the database, so that if you decide you want a new look and feel later, you can apply a new theme and you do not lose any of the content because it's still called through the_content, it's just "wrapped" with a different visual look.

6
  • Thank you for your input, it made a lot of sense to me and I will try to do it in that basic way. I have a questions though: doesnt the index.php always need '<?php get_header(); ?>' and '<?php get_footer(); ?>' to always get these on every page, or ar they atomatically loaded as soon as I have a header.php and footer.php?
    – emcolsson
    Commented Mar 9, 2017 at 10:29
  • Yes, you do have to add those php tags explicitly or the header and footer will not be included. One good guide to start with: codex.wordpress.org/Theme_Development
    – WebElaine
    Commented Mar 9, 2017 at 16:48
  • Hi! Is this a good solution? - A cpl pages in wp, set the Home to front page using settings in Reading. - Homepage_template.php which Home uses with header, menu and footer. I want the menu to be bigger on this page since it has no other content. - Page.php which is set as a template for the other pages. It also have header, menu and footer, but the menu is smaller so content has space. It also contains the loop only to include the_content() and then write this in respective WP-page. - Menu always outside of header and in content-wrapper. - What about Index.php? Do I need it as well?
    – emcolsson
    Commented Mar 16, 2017 at 8:55
  • Take the time to read up on making themes. There is a template called "front-page.php" which you'll want to use for the homepage; setting home to a static page is fine. Yes, 99% of the time you would also want page.php set up differently than your homepage template. Make sure to use body_class in your body tag - that way you'll have CSS classes so you can CSS style your menu bigger on the homepage, smaller on pages. If the menu contains the same content on all pages include it in header, it's always best to consolidate rather than copy code into multiple files.
    – WebElaine
    Commented Mar 16, 2017 at 15:40
  • You should also include index.php as a fallback - what if at some point you add a Post or other post type that you haven't accounted for? You don't have to necessarily create all the possible templates but index.php is your last-resort, "if there is no specific template for this post or this type of post" fallback.
    – WebElaine
    Commented Mar 16, 2017 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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