So, you built a great website in bootstrap. Your site is live and great, works fine in all devices and browsers, everything is perfect. Now, your customer wants to add a blog to your website. WordPress has great themes for blogs but none of them are going to look like your custom website. Here is how you can integrate the WordPress blog into your website and make the blog look same as the rest of your website. You can create your own WordPress theme!
WordPress Blog
WordPress blog is great as it is perfect for content management, backend, and frontend. You can add multiple users, media, plugins, comments, and so on. Backups and versioning is great with WordPress blogs. Corporates have been building full fledged websites using WordPress Divi themes. Inorder to integrate a WordPress blog to your HTML site built using bootstrap, you can follow certain steps and achieve same functionality.
Settings in the cpanel
- First install WordPress in your root folder and give the folder name blog.
- Download bootstrap and save in the wp-content-themes folder.
- Save additional css such as font-awesome and other css you used in your Bootstrap website in the same folder as bootstrap css
- Create new index.php, home.php, header.php, footer.php, sidebar.php, functions.php, page.php, single.php, style.css. Each of the files have their significance in creating your theme in WordPress.
- index.php: Loads your blog
- home.php: Loads the blog posts from the database
- header.php: Loads the header in every post when the get_header() function is called
- footer.php: Loads the footer in every post when the get_footer() function is called
- sidebar.php: Loads the sidebar contents when the get_sidebar() function is called
- functions.php: Needed to load the jQuery in wordpress package to this website and also the sidebar contents
- page.php: Loads the page you create and can act as a template for every page in your WordPress blog or Website
- single.php: Loads the individual post which the user clicks in a page with comments function
- style.css: Loads the styles for this blog
- Edit header.php and copy paste the content including the navbar from your existing website template. Edit the css href to php function bloginfo. Load the stylesheet_url using the function. Add wp_head and wp_enqueue_script to load jquery in this page. Save header.php. In the navbar list, add wp_list_pages function to get the additional blog page you created in the WordPress admin login. This way, your WordPress blog will be at the end of the menu items in your website. After the blog is setup, go ahead and edit all the pages of your website and add menu item blog to link it to the blog page.
- Edit footer.php and copy paste the footer section of your website template. Remove all the javascript functions at the end and add wp_footer() function. Save footer.php.
- Edit sidebar.php and add the function dynamic sidebar to get the sidebar content on all pages and make the sidebars widget friendly. It will load the sidebar contents if there are any existing. Save sidebar.php
- Edit index.php and load the get_header() function first. Next, in a loop check the posts and load the posts and the title and content using the the_title and the_content functions. If there are no posts display a message, saying there are no posts. At the ends, load the get_footer() function.Save index.php
- Edit page.php. Load the header and footer contents. Divide the page into two columns and load the posts in the left column and the sidebar in the right column. Save page.php
- Edit functions.php. Add function to register the scripts such as bootstrap.min.js and script.js in the page. Then enqueue the scripts of your page. Add another function to register the sidebar contents and the before_widget, after_widget, before_title, and after_title style of the sidebar contents. Save functions.php. You can override the default jQuery that comes with the WordPress install with a latest version in the functions.php.
- Edit home.php and load the header, footer and sidebar. In a if condition, check if there are any existing posts. For every post, get the post title, links, content, and date, using respective functions. If there are no posts, display a message. Save home.php. WordPress uses home.php to load the blog posts. Save home.php
- Edit single.php and and load the header, footer and sidebar. Get the contents of the post and get comments section. This page will be loaded if a single post is clicked. Save single.php
- Edit style.css and import the bootstrap, font-awesome, and other css used in your website. Edit the navbar and footer styles to load exactly the same way as the rest of your website. WordPress uses style.css to load the style for your blog. Save style.css.
- If you have multiplepages in your blog, you can have a front-page.php and load the header, footer, and sidebar there.
Settings in the WordPress login
Login to your website and blog using the WordPress credentials. Delete the existing page and create a new page called Blog. In the Settings, go to Readings and set the page to load the latest posts. In the appearance settings select the new them you have created. Go to Live Preview and test the site if it is loading properly. Make your current theme as the default theme for your WordPress and start writing blogs. Voila! you are almost done.
Keep checking for the WordPress updates and backups. Test it in all devices and browsers for responsiveness. Maintain your site and the WordPress blog at the same time with minimal distraction to the user. Add some ads to your blog to make some dollars!! 🙂