0

This might be long but I am facing some confusion about how Wordpress works and do not quite know the right search term to use in google to answer my query .In the pasts I have done web sites using HTML , CSS , JS and PHP . Since the last two months I have been learning about WP so that I can migrate the web site to Worpress . I think I understand what themes and plugins are and went through the code of some of the themes . Theme’s main functions seems to be en queuing all the scripts and styles, create the header ,footer , sidebar , create the blog index page template and some generic pages like archive , 404 etc templates .For individual pages themes seems to show the page content . However , what I fail to understand is if you have to code your own pages where do developers "put" in the HTML code in WP ? Like suppose for my website I have an Our Team Page and About US page whose HTML and CSS I have . What is the best place to put these HTML , CSS in Wordpress ? I understand most developers use Page Builders to do this but what if I want to hand code the pages ? There seems to be two ways to do this :

  1. While creating the Page I can enter the HTML in HTML block of the editor and en queue the required CSS and JS by creating a plugin . The advantage is the content ( that is the HTML ) is actually stored in the database so I can change themes without affecting the content . However , somehow I have a feeling this is not how it is done in practice .

  2. Making using of the template hierarchy . eg creating page-$slug.php and putting in the HTML code there . However , if I change my theme all the page content will go .

Could good people please tell me what is the best practice of coding these static pages in WP without using any page builders ? I feel I have not quite understood the basic idea behind Wordpress till I get this straight . I hope my question makes sense .

2

Welcome to WPSE. Your question will likely be flagged and closed soon (out of scope for this site) but...

Knowing that WordPress is a content management system, your content would ideally be editale in the CMS itself. The short answer to your question is "in the editor - your #1 scenario". The editor supports markup and to avoid extensive rewrites of existing pages, you can simply paste your existing HTML into the editor. Our organization is still using the "classic" editor and has not migrated any of our properties to the new Gutenberg block editor yet, however. We have numerous sites and are just fine NOT using blocks.

Your #2 scenario is done by some developers but the end users are not able to edit the content (easily) this way and the point of a CMS is for end users to easily manage the content. Locking it away in a template is not best practice.

Your challenge will be determining the common header, footer, sidebar areas that can be templated and matching these to the WP ecosystem. If you get stuck in this process, ask a new, direct question regarding your specific problem and you should quickly receive a good, specific 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.