Skip to content
RWC

Project

Personal Karma: A Laravel Back End and WordPress Import for a Self-Improvement Blog

Personal Karma is a self-improvement blog on WordPress. I built a Laravel back end for it: a Voyager admin panel for posts, categories, sliders, pages and menus, a JSON API for a Vue front end, and an import that brings the WordPress posts across.

By Rohit Pippal5 min readComments

Personal Karma is a self-improvement blog. Its homepage greets readers with "Manifest your Potential" and sorts its articles into topics such as Building Wealth, Self Discovery, Pursue Happiness, Think Big, Find Clarity and Mindset. The blog was built on WordPress.

I built a Laravel back end for it: an admin panel where editors run the content, a JSON API that a separate front end reads, and an import that brings the posts across from the WordPress database. The goal was a content system the team could shape themselves, with the articles they already had.

What I built

  • Content model: posts with categories and sub-categories, search engine fields, comments, home page sliders, pages and a front-end menu.
  • Admin panel: Voyager on Laravel, so editors manage every kind of content, the media library, the menu, users and roles from one place.
  • JSON API: posts by id, by category or by address, categories, sub-categories, comments, sliders, pages, site settings, the menu, search and analytics entries.
  • WordPress import: one run that turns the old posts table into posts in the new system, with their status kept.
  • One app for both sides: the same Laravel app serves the Vue front end at every address outside the admin panel and the API.

How it works

Editors

Editors sign in to the admin panel at /admin. A post there has more than a title and a body. It has an excerpt and a short description for lists, a picture, a category and a sub-category, an author, a status (published, draft or pending), a featured flag, and its own search engine fields: an SEO title, a meta description and keywords.

Around the posts, editors manage:

  • categories with a picture and an address, and sub-categories under each main category
  • the sliders at the top of the home page, each with a picture, a title and a text
  • pages, which appear on the site only while they are active
  • comments on posts
  • the site's menu, built with drag and drop, with items nested under each other
  • site settings, users, roles and the media library

Because Voyager reads the database structure, a new kind of content becomes a list, a form and an edit screen in the admin panel without a hand-written screen for each one.

Readers and the front end

Readers never see the admin panel. The front end is a Vue application, and the API gives it what each page needs: the menu, the sliders, the latest posts, a category's posts or one article. Laravel serves that application for every address except /admin and /api, so a reader can open any article link directly and the Vue app takes over from there.

Bringing the WordPress posts across

A new back end is only useful if it starts with the content readers already know. The import reads the posts table of the old WordPress database and creates a post in the new system for every row:

WordPressNew system
Title, excerpt, contentTitle, excerpt, body
Post nameAddress
publishPublished
draftDraft
inherit (revisions and attachments)Pending, for an editor to check
Anything elseDraft

Two details mattered. WordPress keeps revisions and attachments in the same table as the articles, often under the same name as their post. So the import does not publish them: they arrive as pending, and an editor decides. And because those rows can share a name, the import adds a number to every address, so no two posts collide. The guid of each row, WordPress's original address for the item, is kept in the post's picture field, which for an uploaded file is the file itself.

Every imported post starts under the main admin account, so it has an author from the first day.

The API

The API is small on purpose. Every answer is plain JSON, and each endpoint does one job:

  • Posts: all posts, one published post by id, all posts of a category, or one post by its address. Each post comes with its category, sub-category and author name, joined in the same query.
  • One address for two things: the address lookup first looks for a post with that address and, if there is none, for a category with that name. A front end can send whatever is in the browser's address bar and get either an article or a list.
  • Settings: only the settings of the public site group. The admin panel's own settings never leave the server through the API.
  • Menu: the items of the front-end menu with their address, parent and order, so the front end can draw nested menus exactly as the editors arranged them.
  • Search: posts whose title contains the search words, sorted by title, with a clear answer when nothing is found.
  • Pages, sliders, categories, comments and analytics entries: all items, or one by id or name.

What I took from this project

Moving a content site is mostly a question of what the old system really stores. Looking at the WordPress table row by row, rather than trusting its labels, showed that a "post" can be an article, a revision or a file, and that decided how the import had to treat each one.

Tools used

AreaTools
BackendLaravel, PHP, MySQL
Admin panelVoyager
APIJSON endpoints, CORS for the front end
Front endVue, Bootstrap
MigrationA Laravel import from the WordPress database

Do you have a WordPress site that has outgrown its setup? Tell me about it.

Comments

No ratings yet

Log in to comment

Only members can comment and rate posts. It is free and takes a minute.

No comments yet. Be the first to share your thoughts.

All projects
  • Project

    Online Stores

    CoffeeRun: Coffee Ordering and Delivery for Salons and Cafés on Laravel

    CoffeeRun is an Australian Laravel platform where salon clients scan a QR code, order coffee from nearby cafés and get it brought to their chair. I worked on the ordering flow, the Stripe and PayPal checkout, the café dashboard and the admin order screens.

    9 min read
  • Project

    Service Marketplaces

    Bid Learn Grow: A Booking Engine Where Clients Bid for a Coach's Time

    Bid Learn Grow is a Laravel booking engine where clients bid for a coach's time slots. I built the booking and bidding rules, the outbid and winner emails, Google Calendar and Outlook sync, and a booking widget coaches paste into their own websites.

    7 min read