banner



How To Get Html Template For Wordpress

In this guide we'll learn how to easily convert HTML websites to WordPress themes – without coding.

We'll cover WordPress theme structure, using custom mail service types and fields to create the perfect content model, default & custom loops, menus, template parts and everything else that goes into creating an amazing WordPress theme.

You don't need whatever PHP coding skills or experience with WordPress to follow this guide.

The approach described hither works with whatsoever HTML website blueprint, be it hand coded, created in Pinegrow Web Editor, exported from Webflow or any other website builder.

The conversion method is also not tied to any particular framework. Bootstrap, Foundation, evidently HTML, custom frameworks – you are gratuitous to use whatever works best for you.

The result will be a make clean and performant WordPress theme that won't require a agglomeration of bloated plugins to run.

What does it mean to convert HTML to WordPress code?

We can start with a design created in a tool such as Figma, Sketch or Photoshop. The kickoff stride is implementing the design into a static HTML/CSS project.

Or we get-go with an existing HTML website that we would like to manage with WordPress.

In either instance, the WordPress conversion procedure starts with a HTML page, like this one page portfolio with all data difficult-coded into its HTML construction:

A static HTML portfolio page. All information is hard-coded on the page.
A static HTML portfolio page. All information is difficult-coded on the page.

And make it into a dynamic WordPress site where all the content (logo, menus, texts, projects, experiences…) can be edited in WordPress dashboard:

A converted WordPress site with dynamic areas, post collections, menus and functioning forms.
A converted WordPress site with dynamic areas, post collections, menus and functioning forms.

This is done by adding blocks of PHP code that calls WordPress template functions to display dynamic content. For example, the HTML lawmaking that represents the title of the post:

              <h1>The mail service title goes here</h1>            

Becomes the following PHP lawmaking:

              <h1><?php the_title(); ?></h1>            

But doing this by manus is no fun at all. Information technology takes hours of repetitive work, that is not but boring, but also prone to errors.

And the worst part of the transmission arroyo is that we take to repeat the whole process every time we change or re-consign the source HTML files.

At that place is a better, smarter way.

We'll utilise Pinegrow WordPress Theme Architect to catechumen HTML code to WordPress theme.

Pinegrow WordPress Theme Architect

Pinegrow Spider web Editor is a general-purpose HTML and CSS visual editor – information technology tin can work with whatever HTML based project. Information technology is a desktop app for Mac, Windows and Linux that works with projects on our figurer – there is no demand to upload and download anything.

WordPress Theme Architect is a Pinegrow add-on for converting HTML websites into WordPress themes.

WordPress Theme Architect is also available as a standalone application Pinegrow Theme Converter.

When using Pinegrow for editing and styling the HTML projection information technology is the most efficient to employ the integrated WordPress builder. When you're editing the HTML project with some other editor or are exporting the lawmaking from a website builder like Webflow, information technology is best to use the standalone Theme Converter.

How information technology works?

Nosotros open up the source HTML projection in Pinegrow and so click on folio elements and define how they should behave in the WordPress theme.

For example, we select the mail heading and then add the Mail Title action to it.

Display the title of the current post.
Displaying the post title with Post Title action.

As a result of that, the heading will be exported with a WordPress PHP function the_title() that displays the name of the website.

              <h1><?php the_title(); ?></h1>            

Just like in the example before. But hither, we didn't have to write this PHP code by paw. Pinegrow does that for us.

We have two groups of Smart deportment at our disposal: actions for displaying posts with their content and global actions for displaying site data, creating customizable controls, navigation, form processing and more.

Two groups of smart WordPress actions.
Two groups of smart WordPress actions.

Smart actions are powerful, yet unproblematic to use with sensible default settings that just work for most cases. They implement a complete set of CMS features, including:

  • Custom queries
  • Relationships
  • Custom post types
  • Post fields
  • Template parts
  • Menus
  • Pagination
  • Widget areas
  • Tags, categories and custom taxonomies
  • Customizer fields & sections
  • Forms

Another benefit of using smart actions is that they adjust the WordPress output to fit into our custom HTML structure and styling – not the other way around.

What if nosotros need more flexibility?

Alongside smart actions, we likewise take more than 200 regular WordPress actions at our disposal. These deportment represent about i:1 to various WordPress template tags. And, if that's not enough, we can add custom PHP code as well.

Adding custom PHP code to the template.
Calculation custom PHP lawmaking to the template.

No plugins required

Another important indicate is that Pinegrow Theme Converter is not a theme builder like Elementor, Divi and like. It'south as well non a WordPress plugin. Pinegrow is a standalone tool that creates lean, product-ready totally custom WordPress themes that don't require whatever extra WordPress plugins.

Generated PHP code for the WordPress theme.
Generated PHP lawmaking for the WordPress theme.

The output are standard PHP WordPress template files that await but as if a professional person developer would code them past manus. We are gratuitous to do whatever we want with these files – use them as they are, and proceed using Theme Converter to modify them – or customize the code directly.

Liberty to build whatsoever we want

Past now, y'all probably noticed that converting HTML projects to WordPress themes is not a 1-click magical process.

We get to decide how the theme will work. We get to define the perfect information architecture for our site, including using custom mail service types, postal service fields, relationships, queries, taxonomies, customizer fields and more.

You get to do all of that without having to know anything about WordPress functions and PHP code.

Y'all will see – making WordPress themes in this manner is easy and fun.

And practise y'all know what'south the best part?

Utilize your favorite design tools to create WordPress themes

Pinegrow Theme Converter doesn't add WordPress actions directly into source HTML files, and instead stores them in a special file within the project.

Editing the HTML website in Webflow.
Editing the HTML website in Webflow.

That means that nosotros can continue working on the website with our favorite blueprint tool. After making changes – for example in Webflow – we but consign the HTML again, go to Pinegrow Theme Converter, run the Export theme command and our updated WordPress theme is set up.

Let'due south take a look at the details of creating a WordPress theme.

Setting upward the theme

We offset with a HTML source project.

In Theme Settings we decide on the name of the new WordPress theme and its slug.

Setting up the theme information.
Setting upwardly the theme information.

Slug is a WordPress term. It refers to a computer-friendly proper name that is used internally in WordPress code and consists of a single give-and-take that can incorporate just lowercase letters, numbers and the "_" character.

Theme slug is usually related to the theme proper name, for example "pine_cone" is the slug of the theme name "Mr. Pino Cone".

Next nosotros need to decide on the location of the exported theme. That is normally a folder inside "wp-content/themes" in our local WordPress installation. Although the local WordPress install is non required, information technology's strongly recommended because it lets us easily examination the theme and import content back to the source HTML files.

Developing the theme on a local WordPress installation will save a lot of our time. In one case we are sure the theme works we upload it to the production server.

That'due south why we too enter the URL address of the local WordPress site.

If y'all don't take a local copy of WordPress running yet, the easiest way is using Local by Flywheel (easier) or MAMP (more than flexible). Both options are free.

Headers and footers

In theme settings we also select the main file of our theme. That is ordinarily alphabetize.html that is exported to index.php, header.php and footer.php. Past default the content of the body chemical element is saved as index.php, everything before that every bit header.php and everything that comes after, including the closing body tag as footer.php.

              html     body --------------------  <— Everything above is header.php         header         section         section       <— chief template content         section         footer --------------------  <— Everything below is footer.php         script         script            

All other template files (unless they are marked equally chief files) volition utilize the header and footer of the chief file.

Note, we tin can use the Site Content action to slice the page in some other style, if needed.

Check out the complete guide on setting up the theme.

WordPress template files

Every HTML folio in our source project is exported into a corresponding WordPress template PHP file. Names of these PHP files take special meaning for WordPress.

WordPress decides which template file to use based on what it wants to display. If that file is not present, it looks for the next appropriate file. In the end, if no specialized template files are nowadays in the theme, it uses index.php.

For example, take a look at the list of files that WordPress engine goes through when displaying a single page. If the file exists, it is used to display the page, otherwise WordPress looks for the next file in the line.

  1. {custom}.php
  2. page-{id}.php
  3. page-{slug}.php
  4. folio.php
  5. atypical.php
  6. alphabetize.php

In the terminate, index.php is used if other template files are non found. That's why every WordPress theme needs at least the index.php template.

Accept a look at the guide to choosing the right template proper noun for details.

Not every HTML page from our source projection needs to exist exported to the theme. Only pages with active Page settings action are exported.

Settings for exporting the HTML page as a WordPress template file.
Settings for exporting the HTML folio as a WordPress template file.

In Folio settings we decide to which WordPress template to export the page. There we can likewise specify the preview URL that points to the local WordPress URL that displays that template.

At this bespeak nosotros tin can already consign our theme.

Export the theme.
Export the theme.

Exploring the theme structure

If you're curious, explore the files in the exported theme folder. The basic theme construction is already in place, with index.php, footer.php, header.php, functions.php and and then on.

Peeking into alphabetize.php reveals that a lot of required WordPress code is already in place – without us having to do anything even so.

Let's activate the new theme in WordPress admin panel and view the folio. It works, but looks simply like the HTML page, the WordPress content is non displayed still.

Showing posts and The Loop

Every WordPress template needs at least 1 Show Posts activeness displaying The Principal Loop, even if the page displays a single post.

The Loop is a WordPress code construct that iterates through posts and displays them on the page. Array of posts is passed from WordPress engine to the theme. The theme displays the posts with the loop.

Inside the Show Posts loop we display each post's championship, content, images, fields, tags and other information by using the actions from the Mail family unit.

For case, hither we use Show Posts to display the list of the latest posts with their featured image, championship, extract, engagement and tags:

              div.commodity       <— Show Posts action     h2 Championship      <— Post Championship activity     img.featured  <— Post Featured Image     div.conten    <— Post Content action      p.excerpt     <— Mail Extract action      …            

When using Testify Posts with the principal loop, we have no command over how many and what posts are returned in the loop. That's WordPress engine's job. Our theme just displays the posts.

In improver to the main loop posts, we ofttimes need to testify other groups of posts on the aforementioned page. For case, nosotros have related posts listed under the chief content of the folio.

Custom queries

Show Posts with Custom query lets united states fetch posts co-ordinate to custom criteria, for case searching by the post field value.

In this example we evidence the list of featured articles, using "featured" post field as search criteria. We use the selection to filter out whatsoever posts that were already shown higher up the folio.

Defining custom WP_Query.
Showing posts with a custom query.

Custom query Testify Posts action creates the PHP custom WP_Query code. Take a look at the code and run into how much typing Pinegrow saves united states of america – and don't worry, you don't have to understand this code:

              <?php     $experience_query_args = array(         'post_type' => 'experience',         'nopaging' => true,         'lodge' => 'ASC',         'orderby' => 'date'     ) ?> <?php $experience_query = new WP_Query( $experience_query_args ); ?> <?php if ( $experience_query->have_posts() ) : ?>     <?php $experience_query_item_number = 0; ?>     <?php while ( $experience_query->have_posts() ) : $experience_query->the_post(); ?>         <?php if( $experience_query_item_number == 0 ) : ?>             <?php PG_Helper::rememberShownPost(); ?>             <div id="w-node-8f65c72d8fc9-dab46f94" <?php post_class( 'work-position-wrap' ); ?>>                 .... Show the mail here...             </div>         <?php endif; ?>         <?php $experience_query_item_number++; ?>     <?php endwhile; ?>     <?php wp_reset_postdata(); ?> <?php else : ?>     <p><?php _e( 'Sorry, no posts matched your criteria.', 'my_portfolio' ); ?></p> <?php endif; ?>  <!-- Functions.php section Custom Post Types -->      register_post_type('feel', assortment(         'labels' =>              array(                 'name' => __( 'Experiences', 'my_portfolio' ),                 'singular_name' => __( 'Experience', 'my_portfolio' )             ),         'public' => true,         'supports' => assortment( 'championship', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'revisions', 'folio-attributes' ),         'show_in_rest' => true,         'show_in_menu' => true     ));            

Nested Testify Posts actions

Prove Posts actions tin can be nested.

              article      <— Show Posts with the Main loop     h1       <— Post title for the chief mail     p Related     ul       li     <— Show Posts with custom query           a  <— Post title and Post link for the related mail service            

For example, the outer Bear witness Posts deportment displays the posts in the principal loop and the inner Show Posts action displays the list of related articles for each post.

Relationships between content types

Another powerful method is building and retrieving relationships between posts. For example, let'southward imagine we have Projects and Squad members in our posts database. We can define the "team_members" relationship on Projects so that it contains the list of team members who worked on the projection.

Evidence Posts with Relationship lets united states do that.

Showing posts from the relationship field.
Showing posts that are connected to the parent post.

Loop construction

Show Posts also lets u.s. define a flexible loop output construction where we can set what range of elements to repeat, what to display if no posts are plant, which of returned posts to really display and so on.

In the following case, we will:

  • always brandish the section and information technology'south heading.
  • Display div.items but when posts are establish.
  • Display div.empty-loop is no posts are institute.
Defining custom loop structure.
Defining custom loop structure.
              section                        <— Bear witness Posts     h2 Latest posts     div.items                  <— Items container         p Look at this:         article Mail service i         <— Repeated item         commodity Mail 2         <— Don't consign         ...     div.empty-loop             <— Testify chemical element if empty         p No posts were plant            

Accept a wait at the consummate Show Posts documentation for details and examples.

The content model

For all but the most unproblematic projects we need to first accept a practiced look at all the HTML pages and program how the information will be organized.

That ways figuring out what post types we need to represent the information, and custom fields that need to exist added to post types and relationships between objects.

It also ways identifying static and editable parts of the website. For example, section headings might be fixes, while department description texts

Registering custom post types

Postal service types stand for different types of our content. For example, we might have Projects, Squad members, Weblog posts and and so on.

WordPress comes with a set of built-in post types, the chief being posts and pages. We can employ posts for chronological content, for example web log posts, events and projects. Pages are useful for structured content that is not dependent on time, for instance data nearly the company, documentation…

There is no need to cram every type of content into posts and pages. WordPress lets usa register as many custom post types as we need.

And Pinegrow makes defining and using custom mail service types like shooting fish in a barrel. One way to annals a new custom mail service type is directly on the Show Posts action that displays posts of that type.

Register custom post type "experience".
Register custom post blazon "experience".

This will add the custom post type "Experiences" to the main menu in WordPress dashboard.

Custom post type "Experience" in WordPress dashboard.
Custom mail type "Experience" in WordPress dashboard.

Nosotros then use Bear witness Posts activeness to brandish such posts, either with the Main loop in templates that target the custom post blazon (for instance, single-{post blazon}.php), or by using Show Posts with Custom query / Human relationship.

Extending posts with custom fields

Some of these post types besides need additional fields for storing their data. For example, Projects might need extra fields for their clients and elapsing.

In classic WordPress editor (the onetime editor, before Gutenberg / Blocks editor) we could edit custom fields while editing the post.

Just in the new WordPress (5.0+) blocks editor, the custom fields are no longer accessible in the editor.

Our recommendation is to utilise Advanced Custom Fields (ACF) plugin. The gratis version is powerful plenty to handle all apply-cases described in this guide. It's a widely used high-quality plugin that implements powerful and convenient UI for custom fields.

With ACF nosotros define groups of fields and associate them with particular post types.

For example, we define field "elapsing" for mail type Experience.

Defining custom field group for our custom post type.
Defining custom field group for our custom post type.

With this, we're able to edit the field in blocks and classic WordPress editors.

Editing the custom field.
Editing the custom field.

And use Post Field activeness to display or use field values.

Displaying the custom field value.
Displaying the custom field value.

Relationships

Different types of content are ordinarily connected amongst themselves, forming relationships. For example, Projects could be connected with Squad members who worked on them.

Surprisingly, WordPress doesn't come with the back up for relationships out-of-the box. Nosotros tin again utilize gratuitous version of Advanced Custom Fields (ACF) plugin to implement relationships and any custom fields that our mail service types demand.

Relationships are just a special kind of custom post fields – a list of connected posts. When defining a human relationship in ACF we listing the post types that can be added to the list field.

ACF adds a user-friendly UI for managing connected posts:

User interface for editing related posts.
User interface for editing related posts.

And we can utilize Evidence Posts with Human relationship to loop through and display these posts:

Show relationship posts.
Prove human relationship posts.

Tags, categories & custom taxonomies

Posts tin be organized in categories and grouped with tags. In WordPress terminology both categories and tags are taxonomies. We tin can define additional custom taxonomies, if needed. For example, we might define the Activities taxonomy and assign its terms (mountain climbing, trekking, exploring caves…) to Chance Trips in club to bespeak what activities volition happen on trips.

Register new taxonomy.
Evidence and annals new taxonomy.

We can then assign the terms from this taxonomy to private posts:

Add terms to a post.
Assign terms to the postal service.

Use Post Tags & Categories action to display terms associated with the current mail service:

And Site Tags & Categories activity to list all terms that are used on the site, optionally accompanied with the count to associated posts:

Pinegrow Theme Converter lets us work with all of these – Mail types, fields, relationships and taxonomies – in order to build the perfect content model for our WordPress site.

So far we've been mainly talking about working with Posts and their content.

A typical WordPress site tin can have other dynamic – and editable – parts that are not parts of posts.

Making the theme editable with Customizer

WordPress Customizer lets u.s.a. hands edit texts, images, links and styles of any website element. When creating the WordPress theme we have to register all these Customizer controls in functions.php and and so employ appropriate WordPress functions in templates to display the control values.

With Pinegrow Theme Converter that'due south just few clicks of work.

We select the element and add Customizer Field action that modifies element's content, attributes, background image or styles. We can also define global CSS rules that use the customizer values to redefine styling of the site.

For example, here we create a push button that has two editable fields: its link and label.

Add customizer fields on a button.
Add customizer fields button characterization and link.

Customizer controls are grouped in Customizer sections. Again, creating those is piece of cake, using the Customizer Section actions.

With this, we'll be able to edie these fields in WordPress Customizer with live preview:

Customizer Field action can do a lot more, including defining editable CSS rules that control the styling of i or more than HTML elements on the page.

Encounter the complete guide to Customizer Field action for details.

Navigation

In WordPress we have Menus and Card locations. Themes define Carte du jour locations – places where menus can exist shown. In WordPress dashboard nosotros then create menus and assign them to their Menu locations.

Editing menu locations in WordPress dashboard.
Editing carte locations in WordPress dashboard.

To show a menu for a specific location – and optionally annals a new carte location – we just add together the Card activity to the HTML chemical element that represents the navigation.

Adding Menu action to the element that represents the menu.
Calculation Menu action to the element that represents the menu.
              ul.menu            <— Carte du jour action     li             <— Repeated carte particular        a Item i     li                     a Item 2     li                     a Detail ii     ...            

Pinegrow will automatically figure out the HTML structure of card items on the folio – including the class used to mark the active menu detail – and use that to display the WordPress carte.

Past default, WordPress forces its own HTML markup structure for navigation output. This creates conflicts with our custom styling and HTML structure. Only Menu smart action does the opposite – it adjusts the WordPress output to our existing HTML construction.

Check out the Menu guide for details and examples.

Pagination

Post Pagination smart action works in a similar way like navigation in that the resulting WordPress pagination will adjust to our HTML construction, and not the other way around.

Nosotros simply add the Post Pagination action to the pagination element select which chemical element is previous link, which the next and then on.

Displaying custom post pagination.
Displaying custom mail service pagination.

For example, here we implement pagination with side by side and previous links, and showing "folio X of Y".

              div.pagination         <— Post Pagination activeness     a Previous page    <— Previous page element     div         bridge X         <— Current page element         "of"         span Y         <— Total pages element     a Side by side page        <— Next page element            

Meet the Post Pagination documentation for details and examples.

Reusable template parts

What to do with website elements like navigation and footers that are repeated across the pages?

We can ascertain them every bit Reusable template parts on 1 page and include them on all other pages.

Template parts are stored in individual PHP files that are and then included wherever they are used.

Template parts, stored in a subfolder.
Template parts, stored in a subfolder.

We can create Reusable Template Parts for navigation, footer and other elements that are repeated on multiple pages.

For example, here we define the footer template part on the chief page:

Defining a template part for the footer.
Defining a template office for the footer.

And so testify it on other template pages:

Including the template part for the footer.
Including the template part for the footer.

See the Reusable Template Parts documentation to learn more about best practices for using template parts.

Sidebars and widgets

We can turn areas of our theme into dynamic widget areas, or sidebars.

The content of these sidebars is edited through WordPress admin and the customizer.

Editing the sidebar area in WordPress dashboard.
Editing the sidebar surface area in WordPress dashboard.

That is a convenient fashion to include various widgets on the page, either those implemented past WordPress itself or by plugins.

First, we need to register a widget area / sidebar and then nosotros can brandish it in the theme.

We can do both with the Sidebar activeness:

Register the area in the footer as a sidebar.
Register the area in the footer equally a sidebar.

Learn more near Sidebars.

Forms

Imagine we have a nicely designed HTML form on our contact page and we want to store and e-mail course submissions through WordPress.

Normally, that would hateful going through a bunch of WordPress form plugins and struggling with recreating our form in their form builders. At the end, the outcome will never lucifer our source HTML class because all these plugins enforce their own styling and HTML structure.

Wouldn't it be overnice to be able to go on our HTML form as it is and just add submission processing?

That'southward exactly what the Form smart action does.

Adding form processing to HTML form.
Calculation form processing to HTML form.

It lets us transport submissions with email and also store them as private custom postal service type posts viewable through the WordPress admin console.

Saving form submissions as private custom post type.
Saving form submissions as private custom mail service type.

We can then run into submissions in the WordPress dashboard:

Viewing form submissions in WordPress dashboard.
Viewing form submissions in WordPress dashboard.

We can tell it which element to show when the class is successfully submitted and which element to show when it fails.

Form was successfully submitted.
Grade was successfully submitted.

It does all of this without using whatsoever WordPress plugins.

Check out the documentation about the Form action for details and examples.

The result

The result of converting our HTML website to WordPress with Pinegrow Theme Converter is an efficient product-ready WordPress theme that does a lot without using a bunch of bloated WordPress plugins.

And we can do the whole conversion process visually, without writing any PHP code by manus.

Imagine coding the custom queries, customizer controls, navigation and forms by hand! Each of these would require a long tutorial with copy pasting and editing a agglomeration of PHP code.

In one case nosotros take the exported WordPress theme nosotros can do whatever we desire with it – either taking it as a base of operations for farther customization direct in the PHP code – or keeping the workflow in Pinegrow Theme Converter alongside our favorite blueprint tools.

Using the Pinegrow Theme Converter doesn't forcefulness us into one way of doing things. It gives us a well rounded set of powerful time saving tools and leaves our creative liberty intact.

Next steps

This was an overview of creating a WordPress theme.

The best style to learn more virtually WordPress themes is to create a bunch of them for fun. Go through tutorials and read our how-to guides on the fashion.

How To Get Html Template For Wordpress,

Source: https://pinegrow.com/docs/wordpress/convert-html-to-wordpress-theme/

Posted by: erwinwhold1959.blogspot.com

0 Response to "How To Get Html Template For Wordpress"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel