How to Convert a Static WordPress Website into Dynamic

In this world where everything is changing so fast, a static web page can quickly become boring to the readers. In this article, we will show you how to convert a static WordPress website into dynamic. We will start by adding the simple content management property on the website so that administrators can easily change contents from the dashboard. Before this article, we recommend you read our article Convert HTML Template into WordPress Theme in less than 15 Minutes” in order to create a working WordPress theme. In an earlier article, we had created a static WordPress theme from HTML template. In this article, let’s discuss how to add some dynamic property to the already available theme.

What is a static and dynamic website?

A website can be dynamic or static. A static website contains information that remains static or same for all viewers. The information in the static website remains same for a long time. A dynamic website is that website that changes with time, viewer and other factors. By default, WordPress has integrated the dynamic properties in its features. However, you still need to activate and add the dynamic features of WordPress. Let’s integrate some major dynamic features into your website using WordPress core functionalities.

How to Convert a Static WordPress Website into Dynamic

Dynamic Menu and dynamic Sidebar

WordPress allows you to change the menu links and sidebar contents from the admin dashboard. By going to Appearance > Menu, you can easily add pages, posts, categories and even custom links as the menu items. We have already articles showing you how to dynamically integrate the menu to WordPress website. You can start by reading our articles “Beginners Guide on Creating WordPress Menu” to know how to use WordPress menu. If you have created WordPress theme all by yourself and have not activated the WordPress menu feature yet then you can follow our guide on “How to Create Custom Menus for WordPress Themes”. You can also take help of Plugins like Maxmegamenu and  Navception for adding a dynamic menu on your website.

Similarly, you can also add some flexibility to your sidebar by allowing admins to add widgets through Dashboard. WordPress has the wide variety of widgets that you can use on your website. First, you need to register your sidebar for your theme. The detail instruction on how to register the sidebar for any WordPress theme is found in the article, “How to Add a Custom Sidebar in WordPress.
max mega menu- How to Convert a Static WordPress Website into Dynamic

Adding Dynamic Contents with the Loop

If you want to learn how to convert a static WordPress website into dynamic then you must learn to use loop correctly. Loop is an extremely useful feature that is used to dynamically display the multiple posts of a certain category. Instead of just displaying the static contents, you can just display the post contents through the loop.

loop How to Convert a Static WordPress Website into DynamicHere is a general syntax of the loop in WordPress.

<?php
    if ( have_posts() ) {
        while ( have_posts() ) {
             the_post();
             /* Post Content here */
        } // end while
    } // end if
?>

First, you will need to add some posts from admin dashboard on your website. Now to display those posts in your website you can use the loop. Here is a simple loop to display the title, content, posted date, and the category name from your posts.

<?php
    if ( have_posts() ) :
        while ( have_posts() ) :
             the_post();
?>
             <h3><?php the_title(); ?></h3>
             <small>Posted On: <?php the_time('F j, i'); ?> at <?php the_time('g:i a'); ?><br>
             <?php the_category(); ?></small>
             <p><?php the_content(); ?></p>
           
             <br>
<?php
       endwhile;
   endif;
?>

Create Custom Page Templates

A custom page allows you to have different layouts for different pages. There is a special page in WordPress called page.php which is responsible for controlling the appearance of the page. If you want to learn how to convert a static WordPress website into dynamic then you must learn to create various page layout for different pages.You can actually make various layouts for various pages. For example, your About Us page can have a different layout and structure than the Contact Us page.

Also Read:   Follow These 5 Simple Tips to Improve Your Web Development Skills

The easiest way to do this is to create a new PHP file and name it page-pagename.php. For example file with name, page-about-us.php will work as a layout for about us page. You can copy the layout codes in this file from the page.php file and make the required changes.

Since making an individual page template for each page is messy. So we should be the custom page template. To make the custom page template first create a new file and then start by giving the following comment in the file.

<?php
/* Template Name: My First Custom Page */
?>

If you are modifying the third party theme then you should use a child theme. The child theme will preserve your customization in the theme during the theme update. Here is a guide to teach you how to make child them. Upload the file page template file in your theme folder or child theme folder. You can find your theme in /wp-content/themes/.

How to Convert a Static WordPress Website into Dynamic

Now whenever you create or edit a page, you can easily select the template you have recently created. On the page editing screen, you can find a meta box called page attribute. In the page attribute, you will find the option to choose the template. Click the drop down menu and select your custom template. Right now our custom page layout is empty. You can add the HTML, template tag or PHP code in this file according to your need.

Conclusion

The dynamic property of a website is the collection of many features on a theme. All the dynamic properties of a dynamic website cannot be included in one article. Here are the few articles that can help you to make your website more dynamic.

We hope this article on how to convert a static WordPress website into dynamic was helpful. If you think something is missing then feel free to let us know through your comments.

 

The following two tabs change content below.
Kantiman Bajracharya

Kantiman Bajracharya

Kantiman Bajracharya is a freelance web developer. He is a computer geek who has a Bachelor’s degree in Computer Engineering. He has earned lots of satisfied customers while working for numerous successful projects. He is also a WordPress theme creator and web article writer. On free time he likes reading philosophy books, traveling and playing chess.

Share This Post