CS-17: Content Management System using WordPress
B.C.A. (Honours) & B.C.A. (Honours with Research) โ Semester 3 & 4 ยท Effective from June 2024
โฌ Download Complete PDF Version๐ฏ Course Objectives
- Learn how to create custom themes and pages
- Work with custom post types and taxonomies
- Gain in-detail knowledge of the WordPress CMS backend
- Work with widgets and widget areas
- Work with default CMS functions and extend its core
โ Prerequisites
- Basic knowledge of web development (HTML/CSS/PHP basics) and general CMS concepts
๐ Course Outcomes
- Able to configure and administer the WordPress CMS backend confidently
- Able to decide when to use a Custom Post Type vs. a Custom Field
- Able to extend the WordPress core to match project requirements (hooks, shortcodes, widgets)
- Able to design and build a complete, dynamic WordPress theme from scratch
๐ Reference Book
WordPress to Go: How to Build a WordPress Website on Your Own Domain, from Scratch, Even If You Are a Complete Beginner โ Sarah McHarry (Paperback)
๐บ๏ธ Syllabus at a Glance
- What is CMS
- Installation
- Dashboard
- Database
- Install/Activate
- Customizer
- Widget areas
- Plugins
- Template files
- The Loop
- Template tags
- Hooks
- CPT/Taxonomy
- Widget areas (code)
1Introduction, Installation & Configuration
1.1 What is a Content Management System (CMS)?
A Content Management System is software that lets people create, edit, organize, and publish digital content (text, images, video) without needing to write code for every page. It separates content (stored in a database) from presentation (theme/template files), so non-technical users can manage a website through a visual dashboard while the underlying HTML/CSS/PHP is generated dynamically.
Think of a CMS in two layers: the back-end (admin dashboard where content is authored and stored in a database) and the front-end (public-facing pages, assembled at request-time from that stored content plus the active theme's templates). This separation is what allows the same blog post to look completely different after simply switching a theme.
CMS เชเชเชฒเซ เชถเซเช? CMS (เชเชจเซเชเซเชจเซเช เชฎเซเชจเซเชเชฎเซเชจเซเช เชธเชฟเชธเซเชเชฎ) เช เชเชตเซเช เชธเซเชซเซเชเชตเซเชฐ เชเซ เชเซเชจเซ เชฎเชฆเชฆเชฅเซ เชเซเชเชชเชฃ เชตเซเชฏเชเซเชคเชฟ เชเซเชกเชฟเชเช เชเชพเชฃเซเชฏเชพ เชตเชเชฐ เชตเซเชฌเชธเชพเชเช เชชเชฐ เชเชจเซเชเซเชจเซเช (เชฒเชเชพเชฃ, เชซเซเชเชพ, เชตเชฟเชกเชฟเชฏเซ) เชฌเชจเชพเชตเซ, เชฌเชฆเชฒเซ เช เชจเซ เชชเซเชฐเชเชพเชถเชฟเชค เชเชฐเซ เชถเชเซ เชเซ.
CMS เชจเชพ เชฌเซ เชญเชพเช เชนเซเชฏ เชเซ: เชฌเซเช-เชเชจเซเชก (เชเชกเชฎเชฟเชจ เชกเซเชถเชฌเซเชฐเซเชก, เชเซเชฏเชพเช เชเชจเซเชเซเชจเซเช เชกเซเชเชพเชฌเซเชเชฎเชพเช เชธเชเชเซเชฐเชน เชฅเชพเชฏ เชเซ) เช เชจเซ เชซเซเชฐเชจเซเช-เชเชจเซเชก (เชตเซเชฌเชธเชพเชเชเชจเซ เชเชพเชนเซเชฐ เชฌเชพเชเซ, เชเซ เชฅเซเชฎเชจเชพ เชเซเชฎเซเชชเชฒเซเช เชชเซเชฐเชฎเชพเชฃเซ เชคเซเชฏเชพเชฐ เชฅเชพเชฏ เชเซ). เชเชเชฒเซ เช เชฅเซเชฎ เชฌเชฆเชฒเชตเชพเชฅเซ เช เช เชชเซเชธเซเช เชธเชพเชต เช เชฒเช เชฆเซเชเชพเชฏ เชเซ.
Introduction to WordPress
WordPress is a free, open-source CMS written in PHP and backed by a MySQL/MariaDB database. Originally launched in 2003 as a blogging tool, it has grown into the world's most popular CMS, powering a large share of all websites on the internet โ from personal blogs to large e-commerce stores (via WooCommerce) and enterprise sites.
WordPress ships in two flavours students should be able to distinguish: WordPress.org (self-hosted โ you download the software, install it on your own server, and have full control/access to files & database โ this is what this syllabus covers) versus WordPress.com (a hosted service where Automattic manages the server for you, with more restrictions on themes/plugins on free plans).
Features of WordPress
- Open source & free โ free to download, use, and modify (GPL license)
- Themes โ thousands of free/paid designs to change the site's look instantly
- Plugins โ extend functionality (SEO, forms, e-commerce, caching) without coding
- User-friendly dashboard โ WYSIWYG block editor (Gutenberg) for content creation
- SEO friendly โ clean permalink structure, meta tags, sitemap support
- Responsive & mobile-ready themes out of the box
- Multi-user & role management โ Admin, Editor, Author, Contributor, Subscriber
- Media management โ built-in library for images, audio, video, documents
- Custom Post Types & Taxonomies โ model any kind of content (products, portfolios, events)
- Large community & documentation โ extensive support ecosystem
Advantages of WordPress
- Free and open source โ low cost of ownership
- Easy for beginners; no coding required for basic sites
- Massive plugin/theme ecosystem โ rapid development
- SEO-friendly architecture
- Scalable โ from a single blog to enterprise (news portals, e-commerce)
- Regular security updates and an active community
Disadvantages of WordPress
- Frequent plugin/theme updates can cause compatibility conflicts
- Security is dependent on keeping core/plugins updated (common attack target due to popularity)
- Heavy use of plugins can slow site performance
- Customization beyond a point requires PHP/CSS/JS knowledge
- Database-driven โ needs proper backup/maintenance discipline
1.2 Installation of WordPress
WordPress can be installed locally (for learning/development) using a stack like XAMPP/WAMP (Apache + MySQL + PHP), or on live hosting via cPanel/Softaculous or manual upload.
Local Installation Steps (XAMPP)
- Install XAMPP and start the Apache and MySQL modules.
- Download the latest WordPress ZIP from wordpress.org and extract it into
C:\xampp\htdocs\mysite. - Open
phpMyAdmin(http://localhost/phpmyadmin) and create a new database, e.g.wp_mysite. - Visit
http://localhost/mysitein a browser โ the WordPress installer (the "famous 5-minute install") launches. - Enter database name, username (
root), password, and host (localhost). - Set the site title, admin username, password, and email โ click Install WordPress.
- Log in to
/wp-adminwith the created credentials.
เชเชจเซเชธเซเชเซเชฒเซเชถเชจ เชเชฐเชฐ เชเซเชฎ เชเชตเซ เชเซ? เชฎเซเชเชพเชญเชพเชเชจเซ "Database connection" เชญเซเชฒ เชเชเชฒเชพ เชฎเชพเชเซ เชเชตเซ เชเซ เชเชพเชฐเชฃ เชเซ wp-config.php เชซเชพเชเชฒเชฎเชพเช เชกเซเชเชพเชฌเซเชเชจเซเช เชจเชพเชฎ, เชฏเซเชเชฐเชจเซเชฎ, เชชเชพเชธเชตเชฐเซเชก เช
เชฅเชตเชพ เชนเซเชธเซเช เชเซเชเซเช เชฒเชเชพเชฏเซเชฒเซเช เชนเซเชฏ เชเซ. phpMyAdmin เชฎเชพเช เชเชเชจเซ เชกเซเชเชพเชฌเซเชเชจเซเช เชธเชพเชเซเช เชจเชพเชฎ เชเซเช เชเชฐเซ เช
เชจเซ wp-config.php เชฎเชพเช เช เช เชจเชพเชฎ เชฎเซเช เชเชฐเซ.
1.3 WordPress Directory & File Structure
| Folder / File | Purpose |
|---|---|
wp-admin/ | Core files that power the admin dashboard (never edit) |
wp-includes/ | Core WordPress library files, classes, functions (never edit) |
wp-content/themes/ | All installed themes live here โ this is where custom theme development happens |
wp-content/plugins/ | All installed plugins |
wp-content/uploads/ | Media library files, organized by year/month |
wp-config.php | Database connection details, security keys, debug settings |
index.php | Front controller that loads the WordPress bootstrap |
.htaccess | Apache rewrite rules for pretty permalinks |
wp-content. Everything in wp-admin and wp-includes gets overwritten on every core update.1.4 Dashboard Overview
The dashboard (/wp-admin) is the control panel of the site. The left menu gives access to Posts, Media, Pages, Comments, Appearance, Plugins, Users, Tools, and Settings. The main panel shows widgets like "At a Glance" (content counts), "Activity," and "Quick Draft."
Adding, Editing & Deleting Content
- Post: Posts โ Add New โ write title/content โ set Category & Tags โ Publish. Edit via Posts โ All Posts โ click title. Delete moves it to Trash first (permanently deletable from Trash).
- Page: Similar to Posts but for static content (About, Contact) โ Pages don't use categories/tags and support a Page Attributes panel (Template, Parent, Order).
- Category: Posts โ Categories โ add Name, Slug, Parent, Description. Categories are hierarchical (can have parent/child).
- Tag: Posts โ Tags โ flat (non-hierarchical) keywords used for cross-referencing content.
- Media: Media โ Add New, or drag-and-drop directly inside the block editor. Supports images, PDFs, docs, audio, video; each file gets a Title, Alt Text, Caption, and Description, and can be attached to a specific post/page.
1.5 Gutenberg โ The Block Editor
Gutenberg is WordPress's default content editor (since v5.0), where every piece of content โ a paragraph, image, or button โ is a self-contained block that can be added, rearranged (drag handles), and styled individually.
| Block | Use |
|---|---|
| Paragraph | Basic text content |
| Heading / Subheading | H1โH6 section titles |
| Quote | Blockquote styling for citations |
| Image / Cover Image | Single image or a full-width image with overlay text |
| Gallery | Multiple images in a grid |
| Video / Audio | Embed self-hosted or linked media |
| Columns | Multi-column layouts |
| Code | Preformatted code snippets |
| List | Bulleted/numbered lists |
| Button | Call-to-action links styled as buttons |
| Embeds | YouTube, Twitter/X, Instagram and other oEmbed content |
1.6 User Roles & Capabilities
| Role | Capabilities |
|---|---|
| Administrator | Full control โ themes, plugins, users, settings, all content |
| Editor | Publish/manage all posts & pages (own and others'), moderate comments |
| Author | Publish and manage only their own posts |
| Contributor | Write and edit their own posts but cannot publish (awaits review) |
| Subscriber | Manage their own profile only; typically read content, leave comments |
1.7 Settings Overview
- General โ Site Title, Tagline, WordPress/Site Address, Admin Email, Timezone, Date/Time format
- Writing โ default post category/format, "Post via email," update services
- Reading โ homepage display (latest posts / static page), posts per page, search engine visibility
- Discussion โ comment settings, moderation, avatar display
- Media โ image thumbnail/medium/large dimensions, uploads folder organization
- Permalinks โ URL structure (Plain, Day/Name, Month/Name, Post name, Custom) โ "Post name" is the SEO-recommended option
Permalink เชเชเชฒเซ เชถเซเช? Permalink เชเชเชฒเซ เชคเชฎเชพเชฐเซ เชชเซเชธเซเช เชเซ เชชเซเชเชจเซ เชเชพเชฏเชฎเซ (permanent) URL. เชเซ "Plain" เชชเชธเชเชฆ เชเชฐเซ เชคเซ URL เชฎเชพเช ?p=123 เชเซเชตเซเช เช
เชเชฐเซเช เชฆเซเชเชพเชฏ, เชเซ เชจเชพ เชคเซ เชฏเซเชเชฐเชจเซ เชธเชฎเชเชพเชฏ เชจเชพ Google เชจเซ เชเชฎเซ.
"Post name" เชชเชธเชเชฆ เชเชฐเชตเชพเชฅเซ URL เชธเชพเชซ เช
เชจเซ เชธเชฎเชเซ เชถเชเชพเชฏ เชคเซเชตเซเช เชฌเชจเซ เชเซ (เชฆเชพ.เชค. /my-first-post/), เชเซ SEO เชฎเชพเชเซ เชถเซเชฐเซเชทเซเช เชเชฃเชพเชฏ เชเซ โ เชคเซเชฅเซ เช เชชเชฐเซเชเซเชทเชพเชฎเชพเช เช
เชจเซ เชชเซเชฐเซเชเซเชเชฟเชเชฒเชฎเชพเช เช เชธเซเชเชฟเชเช เชธเซเชฅเซ เชตเชงเซ เชญเชฒเชพเชฎเชฃ เชเชฐเชตเชพเชฎเชพเช เชเชตเซ เชเซ.
1.8 Updating WordPress
- One-click Update โ Dashboard โ Updates โ click "Update Now" (recommended, safest for minor/major releases)
- Manual Update โ download the new version from wordpress.org, back up the database and files, replace
wp-adminandwp-includesfolders, then re-run/wp-admin/upgrade.php
1.9 Database Structure
WordPress uses a relational database (MySQL). Default core tables (prefix wp_):
| Table | Stores |
|---|---|
| wp_posts | Posts, pages, custom post types, revisions, attachments |
| wp_postmeta | Custom fields / meta data linked to a post |
| wp_users | User accounts |
| wp_usermeta | Extra user meta data (role, nickname, capabilities) |
| wp_terms | Categories, tags, and custom taxonomy terms |
| wp_term_taxonomy | Describes the taxonomy each term belongs to |
| wp_term_relationships | Links posts to terms (categories/tags) |
| wp_comments | Comments on posts |
| wp_commentmeta | Meta data about comments |
| wp_options | Site-wide settings (site title, active theme, plugin options) |
| wp_links | Legacy "Blogroll" links feature |
Notice that a post's category/tag isn't stored directly on the post row โ it goes through wp_term_relationships, which links a post ID to a term_taxonomy_id. This indirection (many-to-many relationship) is what lets one post belong to multiple categories, and one category hold many posts, efficiently.
เชกเซเชเชพเชฌเซเช เชเซเชฎ เชฎเชนเชคเซเชตเชจเซเช เชเซ? WordPress เชจเซ เชฆเชฐเซเช เชชเซเชธเซเช, เชชเซเช, เชฏเซเชเชฐ เช
เชจเซ เชธเซเชเชฟเชเช เชกเซเชเชพเชฌเซเช (MySQL) เชฎเชพเช เชเซเชฌเชฒ เชธเซเชตเชฐเซเชชเซ เชธเชเชเซเชฐเชนเชพเชฏ เชเซ. wp_posts เชเซเชฌเชฒเชฎเชพเช เชชเซเชธเซเช/เชชเซเชเชจเซเช เชฒเชเชพเชฃ เชนเซเชฏ เชเซ, wp_users เชฎเชพเช เชฏเซเชเชฐเชจเซ เชฎเชพเชนเชฟเชคเซ, เช
เชจเซ wp_options เชฎเชพเช เชธเชพเชเชเชจเซ เชธเซเชเชฟเชเชเซเชธ (เชเซเชฎ เชเซ เชเช เชฅเซเชฎ เชเชเซเชเชฟเชต เชเซ) เชธเชเชเซเชฐเชนเชพเชฏ เชเซ.
เชเซเชเซเชเชฐเซ เช
เชจเซ เชชเซเชธเซเช เชตเชเซเชเซเชจเซ เชธเชเชฌเชเชง เชธเซเชงเซ เชจเชฅเซ เชนเซเชคเซ โ เชคเซ wp_term_relationships เชจเชพเชฎเชจเชพ เช
เชฒเช เชเซเชฌเชฒ เชฎเชพเชฐเชซเชคเซ เชเซเชกเชพเชฏ เชเซ, เชเซเชฅเซ เชเช เชชเซเชธเซเชเชจเซ เชเชเชฅเซ เชตเชงเซ เชเซเชเซเชเชฐเซเชฎเชพเช เชฎเซเชเซ เชถเชเชพเชฏ.
๐งช Unit 1 โ Lab Practicals
- Install XAMPP/WAMP and set up a local WordPress installation using phpMyAdmin.
- Explore the WordPress directory structure and identify wp-config.php settings.
- Create 5 posts using different Gutenberg blocks (Heading, Image, Gallery, Quote, List).
- Create categories (with a parent-child hierarchy) and tags; assign them to posts.
- Upload media files (image, PDF) to the Media Library and attach one to a page.
- Create 3 users with different roles (Editor, Author, Contributor) and test their permissions by logging in as each.
- Configure General, Reading, and Permalink settings; verify the resulting URL structure.
- Use phpMyAdmin to inspect wp_posts and wp_options tables after creating content.
2Theme
2.1 What is a Theme?
A WordPress theme is a collection of template files, stylesheets, and (optionally) JavaScript/images that together define the visual presentation and layout of a site. Themes control how content stored in the database is displayed, without touching the content itself โ the same posts can look completely different under a new theme.
เชฅเซเชฎ เชถเซเช เชเซ? เชฅเซเชฎ เช เชซเชพเชเชฒเซเชจเซ เชธเชฎเซเชน เชเซ เชเซ เชจเชเซเชเซ เชเชฐเซ เชเซ เชเซ เชตเซเชฌเชธเชพเชเช เชเซเชตเซ เชฆเซเชเชพเชถเซ โ เชฐเชเชเซ, เชซเซเชจเซเช, เชฒเซเชเชเช. เชเชจเซเชเซเชจเซเช (เชชเซเชธเซเช/เชชเซเช) เชกเซเชเชพเชฌเซเชเชฎเชพเช เช เชฒเช เชธเชเชเซเชฐเชนเชพเชฏ เชเซ, เชเชเชฒเซ เชฅเซเชฎ เชฌเชฆเชฒเชตเชพเชฅเซ เชเชจเซเชเซเชจเซเช เชกเชฟเชฒเซเช เชจเชฅเซ เชฅเชคเซเช, เชซเชเซเชค เชคเซเชจเซ เชฆเซเชเชพเชต เชฌเชฆเชฒเชพเชฏ เชเซ.
2.2 How to Install & Activate a Theme
- Go to Appearance โ Themes โ Add New.
- Search the WordPress.org theme repository, or click Upload Theme to install a downloaded
.zipfile. - Click Install, then Activate to make it the live theme.
- Alternatively, upload the theme folder directly to
wp-content/themes/via FTP, then activate it from Appearance โ Themes.
2.3 Theme Customize Options (Appearance โ Customize)
| Option | What it Controls |
|---|---|
| Site Identity | Site title, tagline, logo, and site icon (favicon) |
| Menus | Create/assign navigation menus to theme locations (header, footer) |
| Widgets | Add/arrange widgets into the theme's registered widget areas |
| Homepage Settings | Choose whether the homepage shows the latest posts or a static page |
| Additional CSS | Add custom CSS live, with instant preview, without editing theme files |
Building a Navigation Menu โ Step by Step
- Go to Appearance โ Menus โ create a new menu, give it a name (e.g. "Primary Menu").
- Tick the Pages/Posts/Categories to add from the left panel, click Add to Menu.
- Drag items to reorder; drag an item slightly right and drop it under another to make it a sub-menu (dropdown).
- Under Menu Settings, tick the theme location (e.g. "Primary Menu") to assign it, then Save Menu.
๐งช Unit 2 โ Lab Practicals
- Install and activate two different free themes from the repository; compare their layouts.
- Set Site Identity โ upload a logo and site icon, set title & tagline.
- Create a custom navigation menu and assign it to the header location.
- Configure the homepage to display a static "Home" page instead of the blog feed.
- Add custom CSS via the Customizer to change the site's primary color/fonts.
3Widget & Plugin
3.1 What is a Widget & Widget Area?
A widget is a small, self-contained block of content or functionality (e.g., a search box, recent posts list, calendar) that can be dragged into a widget area โ a theme-defined region such as a sidebar or footer โ without writing code.
Available Widgets
Archive ยท Calendar ยท Categories ยท Navigation Menu ยท Meta ยท Pages ยท Recent Comments ยท Recent Posts ยท RSS ยท Search ยท Tag Cloud ยท Text ยท Image ยท Gallery ยท Video ยท Audio ยท Custom HTML
Widget Management
Managed via Appearance โ Widgets (block-based widgets screen) or through the Customizer's Widgets panel. Widgets can be dragged between areas, reordered, and configured with their own settings (title, number of items, etc.).
Inactive Sidebar / Inactive Widgets
When a theme is switched, widgets from areas that no longer exist in the new theme are automatically moved to an Inactive Widgets bin rather than being deleted โ so they can be restored later if you switch back or the new theme adds a matching area.
3.2 Plugins
What is a Plugin?
A plugin is a packaged piece of PHP code that hooks into WordPress core to add or extend functionality โ e.g., SEO tools, contact forms, e-commerce, caching โ without modifying core files, so features survive core/theme updates.
Widget เช เชจเซ Plugin เชตเชเซเชเซ เชซเชฐเช: Widget เช เชจเชพเชจเซเช, เชคเซเชฏเชพเชฐ content block เชเซ (เชเซเชฎ เชเซ Search box) เชเซ เชซเชเซเชค drag-and-drop เชเชฐเซเชจเซ sidebar/footer เชฎเชพเช เชฎเซเชเซ เชถเชเชพเชฏ โ เชคเซเชจเชพ เชฎเชพเชเซ เชเซเชกเชฟเชเชเชจเซ เชเชฐเซเชฐ เชจเชฅเซ.
Plugin เช เชฎเซเชเซเช, เชธเชเชชเซเชฐเซเชฃ เชซเซเชเชฐ เชเชฎเซเชฐเชคเซเช เชธเซเชซเซเชเชตเซเชฐ เชเซ (เชเซเชฎ เชเซ เชเชเซเช Contact Form เชธเชฟเชธเซเชเชฎ, เช เชฅเชตเชพ SEO เชเซเชฒ) เชเซ WordPress เชจเซ เชเซเชทเชฎเชคเชพ เชตเชงเชพเชฐเซ เชเซ. เชเชฃเซ เชตเชเชค เชเช plugin เชชเซเชคเชพเชจเซเช widget เชชเชฃ เชฌเชจเชพเชตเซ เชเซ.
How to Install & Activate a Plugin
- Plugins โ Add New โ search the repository โ Install Now โ Activate.
- Or Upload Plugin to install a downloaded
.zipfile. - Or upload the plugin folder to
wp-content/plugins/via FTP, then activate from the Plugins screen.
Useful Plugins for a Website
| Plugin | Purpose |
|---|---|
| SEO โ Yoast | On-page SEO analysis, meta tags, XML sitemap |
| Contact Form 7 | Build and manage contact forms |
| WooCommerce | Turns WordPress into a full e-commerce store |
| WP Super Cache | Page caching to improve performance |
| Regenerate Thumbnails | Rebuilds image thumbnail sizes after a theme change |
| Advanced Custom Fields (ACF) | Adds custom meta-box fields to posts/pages/CPTs |
| All-in-One WP Migration | Exports/imports an entire site (files + DB) for migration |
| Custom Post Type Widgets | Display custom post type content in widget areas |
๐งช Unit 3 โ Lab Practicals
- Add Search, Recent Posts, and Categories widgets to the sidebar; reorder them.
- Switch the active theme and observe widgets moving to the Inactive Widgets area; restore them.
- Install and activate Yoast SEO; run an SEO analysis on a sample post.
- Install Contact Form 7; build and embed a contact form on a page using its shortcode.
- Install WooCommerce and add one sample product to the store.
4Theme Development
4.1 Anatomy of a Theme
Every page render in WordPress typically stitches together three re-usable pieces โ header.php, footer.php, and optionally sidebar.php โ around the page-specific template that runs the Loop.
Minimum Required & Common Template Files
| File | Role |
|---|---|
| style.css | Required. Contains theme metadata comment header (Name, Author, Version) + CSS rules |
| index.php | Required fallback template โ the main/blog template |
| header.php | Opening HTML, <head>, site branding, nav menu |
| footer.php | Closing HTML, footer widgets/credits, wp_footer() hook |
| sidebar.php | Sidebar widget area markup |
| page.php | Template for static Pages |
| home.php | Template for the blog posts index (if different from front page) |
| archive.php | Template for date/author/CPT archive listings |
| single.php | Template for a single blog post |
| comments.php | Comment form and comment list markup |
| search.php | Search results template |
| attachment.php | Template for viewing a single media attachment |
| 404.php | "Page not found" template |
| category.php / tag.php | Category-specific / tag-specific archive templates |
| author.php | Author archive template |
| date.php | Date-based archive template |
The Template Hierarchy
WordPress decides which template file to load for a given URL by walking a fixed priority order โ the Template Hierarchy โ from most specific to most general, always falling back to index.php if nothing more specific exists.
Template Hierarchy เชเชเชฒเซ เชถเซเช? เชเซเชฏเชพเชฐเซ เชเซเช เชฏเซเชเชฐ เชตเซเชฌเชธเชพเชเช เชชเชฐ เชเซเช page เชเซเชฒเซ, เชคเซเชฏเชพเชฐเซ WordPress เชจเชเซเชเซ เชเชฐเซ เชเซ เชเซ เชเช เชเซเชฎเซเชชเชฒเซเช เชซเชพเชเชฒ เชตเชพเชชเชฐเชตเซ. เชคเซ เชชเชนเซเชฒเชพ เชธเซเชฅเซ เชเซเชเซเชเชธ (specific) เชซเชพเชเชฒ เชถเซเชงเซ เชเซ โ เชฆเชพ.เชค. เชเช movie เชชเซเชธเซเช เชฎเชพเชเซ single-movie.php โ เช
เชจเซ เชเซ เช เชจเชพ เชฎเชณเซ เชคเซ เชธเชพเชฎเชพเชจเซเชฏ เชซเชพเชเชฒ เชคเชฐเชซ เชเชพเชฏ เชเซ, เชเซเชฒเซเชฒเซ index.php เชธเซเชงเซ, เชเซ เชฆเชฐเซเช เชฅเซเชฎเชฎเชพเช เชนเซเชตเซ เช เชเซเชเช.
4.2 The Loop
The Loop is the core PHP construct that WordPress uses to display posts. It iterates over the post(s) matched by the current query and, for each one, sets up post data so template tags like the_title() work correctly.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<div><?php the_content(); ?></div>
<?php endwhile; else : ?>
<p>No posts found.</p>
<?php endif; ?>
WP_Query must end with wp_reset_postdata(); to restore the main query's global $post object.The Loop เชถเซเช เชเซ? The Loop เช PHP เชจเซ เชเชตเซ เชเซเชก เชเซ เชเซ เชเช เชชเชเซ เชเช เชฌเชงเซ เชชเซเชธเซเช เชคเชชเชพเชธเซ เชเซ เช
เชจเซ เชฆเชฐเซเชเชจเซ เชธเซเชเซเชฐเซเชจ เชชเชฐ เชฌเชคเชพเชตเซ เชเซ. have_posts() เชเซเช เชเชฐเซ เชเซ เชเซ เชนเชเซ เชชเซเชธเซเช เชฌเชพเชเซ เชเซ เชเซ เชจเชนเซเช, เช
เชจเซ the_post() เชเชเชฒเซ เชชเซเชธเซเชเชจเซ เชกเซเชเชพ เชคเซเชฏเชพเชฐ เชเชฐเซ เชเซ โ เชคเซเชฏเชพเชฐ เชชเชเซ เช the_title() เช
เชจเซ the_content() เชเซเชตเชพ เชเซเช เชธเชพเชเซเช เชเชเชเชชเซเช เชเชชเซ เชเซ.
เชธเชนเซเชฒเซ เชฐเซเชคเซ เชฏเชพเชฆ เชฐเชพเชเซ: "เชเซเชฏเชพเช เชธเซเชงเซ เชชเซเชธเซเช เชเซ เชคเซเชฏเชพเช เชธเซเชงเซ โ เชเชเชฒเซ เชชเซเชธเซเช เชฒเซ, เช เชจเซ เชเชจเซ เชเชพเชชเซ."
4.3 Template Tags
Template Tag เชเชเชฒเซ เชถเซเช? Template Tag เช PHP เชจเซเช เชซเชเชเซเชถเชจ เชเซ เชเซ เชฅเซเชฎ เชซเชพเชเชฒเซเชฎเชพเช เชตเชพเชชเชฐเซเชจเซ เชกเซเชเชพเชฌเซเชเชฎเชพเชเชฅเซ เชกเซเชเชพ (เชเชพเชเชเชฒ, เชเชจเซเชเซเชจเซเช, เชคเชพเชฐเซเช, เชฒเซเชเชเชจเซเช เชจเชพเชฎ เชตเชเซเชฐเซ) เชฎเซเชณเชตเซเชจเซ เชธเซเชเซเชฐเซเชจ เชชเชฐ เชฌเชคเชพเชตเซ เชเซ. เชฆเชพ.เชค. the_title() เชชเซเชธเซเชเชจเซเช เชเชพเชเชเชฒ เชเชพเชชเซ เชเซ, the_content() เชเชเซเช เชฒเชเชพเชฃ เชเชพเชชเซ เชเซ.
เชฏเชพเชฆ เชฐเชพเชเชตเชพเชจเซ เชธเชนเซเชฒเซ เชฐเซเชค: เชจเชพเชฎเชฎเชพเช "the_" เชนเซเชฏ เชคเซ เชธเซเชงเซเช เชเชพเชชเซ (echo), เช เชจเซ "get_the_" เชนเซเชฏ เชคเซ เชตเซเชฒเซเชฏเซ เชชเชพเชเซ เชเชชเซ (return) โ เชเซเชจเซ เชคเชฎเซ เชเชฒ (variable) เชฎเชพเช เชธเชเชเซเชฐเชนเซ เชถเชเซ.
General Tags
wp_head(), get_footer(), get_header(), get_sidebar(), get_search_form(), bloginfo(), wp_title(), single_post_title(), wp_footer(), comments_template(), add_theme_support(), get_template_directory_uri(), body_class()
These load reusable template parts, output <head>/footer hooks required by plugins, print site info (name, URL, description via bloginfo()), register theme features (add_theme_support('post-thumbnails')), and output dynamic CSS classes on the <body> tag.
Author Tags
the_author(), get_the_author(), the_author_link(), get_the_author_link(), the_author_meta(), the_author_posts() โ display the post author's name, profile link, custom meta (bio, website) and post count.
Category Tags
category_description(), single_cat_title(), the_category() โ output category descriptions, the current category archive title, and the list of categories a post belongs to.
Link Tags
the_permalink(), get_permalink(), home_url(), get_home_url(), site_url(), get_site_url() โ return/print canonical URLs for the current post or the site root.
Post Tags
the_content(), the_excerpt(), the_ID(), the_tags(), the_title(), get_the_title(), the_date(), get_the_date(), the_time(), next_post_link(), previous_post_link(), posts_nav_link(), post_class() โ the core set used inside the Loop to print a post's body, summary, ID, tags, title, date/time, pagination links between posts, and dynamic CSS classes on the post wrapper.
Post Thumbnail Tags
has_post_thumbnail(), get_post_thumbnail_id(), the_post_thumbnail(), get_the_post_thumbnail() โ check for and output the Featured Image (requires add_theme_support('post-thumbnails') in functions.php).
Navigation Menu Tag
wp_nav_menu( array('theme_location' => 'primary') ) โ outputs a menu previously registered with register_nav_menu() and assigned by the user under Appearance โ Menus.
Conditional Tags
is_archive(), is_category(), is_front_page(), is_home(), is_page(), is_single(), is_search(), is_attachment(), is_active_sidebar() โ booleans used to branch template logic based on the type of page currently being viewed (e.g., show a different header on the front page).
<?php if ( is_front_page() ) : ?>
<div class="hero">Welcome banner</div>
<?php elseif ( is_single() ) : ?>
<div class="post-meta"><?php the_date(); ?></div>
<?php endif; ?>
4.4 functions.php
The functions.php file acts like a plugin built into the theme โ it runs automatically on every page load and is the standard place to register menus, widget areas, theme support, enqueue styles/scripts, and hook in custom PHP functions (covered further in Unit 5).
<?php
function mytheme_setup() {
add_theme_support( 'post-thumbnails' );
add_theme_support( 'title-tag' );
register_nav_menu( 'primary', 'Primary Menu' );
}
add_action( 'after_setup_theme', 'mytheme_setup' );
functions.php เชถเชพ เชฎเชพเชเซ เชเชพเชธ เชเซ? เช เชซเชพเชเชฒ เชฅเซเชฎเชจเซ เช
เชเชฆเชฐ เชฐเชนเซเชฒเซ "mini plugin" เชเซเชตเซ เชเซ โ เชคเซ เชฆเชฐเซเช เชชเซเช เชฒเซเชก เชฅเชพเชฏ เชคเซเชฏเชพเชฐเซ เชเชชเซเชเชช เชเชพเชฒเซ เชเซ. เชคเซเชฎเชพเช เชคเชฎเซ เชฎเซเชจเซ เชฐเชเชฟเชธเซเชเชฐ เชเชฐเซ เชถเชเซ, เชฅเซเชฎเชจเชพ เชซเซเชเชฐเซเชธ เชเชพเชฒเซ เชเชฐเซ เชถเชเซ (เชเซเชฎ เชเซ Featured Image), เช
เชจเซ เชชเซเชคเชพเชจเชพ เชเชธเซเชเชฎ เชซเชเชเซเชถเชจ เชฌเชจเชพเชตเซ เชถเชเซ โ เช เชฌเชงเซเช wp-content เชจเซ เชฌเชนเชพเชฐ เชเชเช เชซเซเชฐเชซเชพเชฐ เชเชฐเซเชฏเชพ เชตเชเชฐ.
๐งช Unit 4 โ Lab Practicals
- Build a theme from scratch with style.css, index.php, header.php, footer.php, sidebar.php.
- Write the Loop in index.php to list all posts with title, excerpt, and date.
- Create single.php and page.php with distinct layouts using conditional tags.
- Register a navigation menu in functions.php and output it with wp_nav_menu().
- Add Featured Image support and display it using the_post_thumbnail() on single.php.
- Use is_front_page(), is_single(), is_page() to conditionally change layout/markup.
5Advanced Development
5.1 Advanced Functions โ Hooks & Shortcodes
| Function | Purpose |
|---|---|
add_action( $hook, $callback ) | Attaches a custom function to run when WordPress reaches a specific point (e.g. init, wp_enqueue_scripts) |
add_filter( $hook, $callback ) | Attaches a function that receives a value, modifies it, and must return it (e.g. altering the_title) |
add_shortcode( $tag, $callback ) | Registers a reusable [shortcode] that editors can insert into post/page content |
do_shortcode( $content ) | Manually parses and executes shortcodes inside a string (useful in template files) |
register_nav_menu( $location, $desc ) | Declares a menu location a theme supports, so it appears under Appearance โ Menus |
// Custom shortcode: [greet name="Alpesh"]
function greet_shortcode( $atts ) {
$atts = shortcode_atts( array( 'name' => 'Guest' ), $atts );
return "Hello, " . esc_html( $atts['name'] ) . "!";
}
add_shortcode( 'greet', 'greet_shortcode' );
// Filter example: force all titles to uppercase
add_filter( 'the_title', function( $title ) {
return strtoupper( $title );
});
Action Hook vs Filter Hook เชจเซ เชซเชฐเช: Action Hook (add_action) เช "เชเชเชเช เชเชฐเชตเชพ" เชฎเชพเชเซ เชตเชชเชฐเชพเชฏ เชเซ โ เชเซเชฎ เชเซ เชเชฎเซเชฒ เชฎเซเชเชฒเชตเซ, เชกเซเชเชพ เชธเซเชต เชเชฐเชตเซ. เชคเซ เชเชเช เชชเชพเชเซเช (return) เชจเชฅเซ เชเชชเชคเซเช.
Filter Hook (add_filter) เช "เชเซเช เชตเซเชฒเซเชฏเซ เชฌเชฆเชฒเชตเชพ" เชฎเชพเชเซ เชตเชชเชฐเชพเชฏ เชเซ โ เชคเซ เชเช เชตเซเชฒเซเชฏเซ เชฒเซ เชเซ, เชคเซเชฎเชพเช เชซเซเชฐเชซเชพเชฐ เชเชฐเซ เชเซ, เช
เชจเซ เชซเชฐเชเชฟเชฏเชพเชค เชชเชพเชเซ (return) เชเชชเชตเซ เชชเชกเซ เชเซ. เชฆเชพ.เชค. เชชเซเชธเซเชเชจเซเช เชเชพเชเชเชฒ เชฎเซเชเชพ เช
เชเซเชทเชฐเซเชฎเชพเช เชฌเชคเชพเชตเชตเซเช.
เชธเชนเซเชฒเซ เชฐเซเชคเซ: Action = "เชเชเชเช เชเชฐเซ", Filter = "เชเชเชเช เชฌเชฆเชฒเซเชจเซ เชชเชพเชเซเช เชเชชเซ".
5.2 Custom Post Types & Taxonomies
A Custom Post Type (CPT) lets you model content beyond posts/pages โ e.g., "Movies," "Products," "Events." A Custom Taxonomy lets you classify that content โ e.g., "Genre" for Movies.
// Register a "Movie" Custom Post Type
function register_movie_cpt() {
register_post_type( 'movie', array(
'labels' => array( 'name' => 'Movies', 'singular_name' => 'Movie' ),
'public' => true,
'has_archive' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'menu_icon' => 'dashicons-video-alt2',
));
}
add_action( 'init', 'register_movie_cpt' );
// Register a "Genre" taxonomy for Movies
function register_genre_taxonomy() {
register_taxonomy( 'genre', 'movie', array(
'label' => 'Genre',
'hierarchical' => true,
'public' => true,
));
}
add_action( 'init', 'register_genre_taxonomy' );
Displaying a CPT & its taxonomy: create archive-movie.php (list view, uses the normal Loop against the CPT), single-movie.php (detail view), and taxonomy-genre.php (genre archive) โ WordPress' Template Hierarchy automatically picks these files up.
Custom Post Type (CPT) เช
เชจเซ Taxonomy เชถเซเช เชเซ? เชธเชพเชฎเชพเชจเซเชฏ เชฐเซเชคเซ WordPress เชฎเชพเช เชซเชเซเชค "Post" เช
เชจเซ "Page" เช เชนเซเชฏ เชเซ. เชชเชฃ เชเซ เชคเชฎเชพเชฐเซ "Movie", "Product" เชเซ "Event" เชเซเชตเซ เช
เชฒเช เชชเซเชฐเชเชพเชฐเชจเซ เชเชจเซเชเซเชจเซเช เชฌเชจเชพเชตเชตเซ เชนเซเชฏ, เชคเซ register_post_type() เชตเชพเชชเชฐเซเชจเซ เชชเซเชคเชพเชจเซ Custom Post Type เชฌเชจเชพเชตเซ เชถเชเชพเชฏ.
Taxonomy เช CPT เชจเซ เชตเชฐเซเชเซเชเซเชค (categorize) เชเชฐเชตเชพเชจเซ เชฐเซเชค เชเซ โ เชเซเชฎ เชเซ "Movie" เชฎเชพเชเซ "Genre" (Action, Comedy, Drama) โ เช register_taxonomy() เชตเชกเซ เชฌเชจเซ เชเซ. เชเซเชเชเชฎเชพเช: CPT = เชจเชตเซ เชเชจเซเชเซเชจเซเช เชชเซเชฐเชเชพเชฐ, Taxonomy = เช เชเชจเซเชเซเชจเซเชเชจเซ เชเซเช เชตเชตเชพเชจเซ เชฐเซเชค.
5.3 Widget Areas โ register_sidebar() & dynamic_sidebar()
// Register a custom widget area in functions.php
function mytheme_widgets_init() {
register_sidebar( array(
'name' => 'Footer Widget Area',
'id' => 'footer-widgets',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}
add_action( 'widgets_init', 'mytheme_widgets_init' );
// Output the widget area in footer.php
<?php if ( is_active_sidebar( 'footer-widgets' ) ) : ?>
<?php dynamic_sidebar( 'footer-widgets' ); ?>
<?php endif; ?>
register_sidebar() เช
เชจเซ dynamic_sidebar() เชจเซ เชซเชฐเช: register_sidebar() เช เชจเชตเซ widget area เชฌเชจเชพเชตเชตเชพ เชฎเชพเชเซ เชตเชชเชฐเชพเชฏ เชเซ โ เชคเซ functions.php เชฎเชพเช เชซเชเซเชค เชเช เช เชตเชพเชฐ เชฒเชเชพเชฏ เชเซ, เชเซเชฎ เชเซ "Footer Widget Area" เชเชพเชนเซเชฐ เชเชฐเชตเซเช.
dynamic_sidebar() เช เชชเซเชฒเชพ area เชฎเชพเช เชฏเซเชเชฐเซ เชเซ widgets เชฎเซเชเซเชฏเชพ เชนเซเชฏ เช เชเชฐเซเชเชฐ เชเชพเชชเชตเชพ เชฎเชพเชเซ เชตเชชเชฐเชพเชฏ เชเซ โ เชคเซ footer.php เชเซ sidebar.php เชเซเชตเซ เชเซเชฎเซเชชเชฒเซเช เชซเชพเชเชฒเชฎเชพเช เชฒเชเชพเชฏ เชเซ. เชเซเชเชเชฎเชพเช: register = เชเชเซเชฏเชพ เชฌเชจเชพเชตเซ, dynamic_sidebar = เช เชเชเซเชฏเชพเชจเซเช เชเชจเซเชเซเชจเซเช เชฌเชคเชพเชตเซ.
๐งช Unit 5 โ Lab Practicals
- Register a custom shortcode and use it inside a page's content.
- Write a filter that modifies post excerpts (e.g., custom "Read more" text).
- Create a "Testimonial" Custom Post Type with a "Rating" custom taxonomy.
- Build archive-testimonial.php and single-testimonial.php templates to display it.
- Register a new widget area ("Footer Widgets") and display it with dynamic_sidebar().
- Combine add_action + register_nav_menu to add a secondary "Footer Menu" location.
18CS-18 ยท Consolidated Practical / Lab List
CS-18 is the dedicated MDC practical paper covering CS-15 (C++ OOP), CS-16 (RDBMS/Oracle) and CS-17 (WordPress). The WordPress-specific practical checklist below consolidates the unit-wise practicals above into an exam-ready sequence:
- Install WordPress locally using XAMPP and phpMyAdmin.
- Create posts/pages using various Gutenberg blocks; manage categories & tags.
- Manage the Media Library โ upload, edit metadata, insert into content.
- Create and test multiple user roles and their capabilities.
- Install, activate, and customize a theme (logo, menu, homepage, custom CSS).
- Add and arrange widgets; observe inactive-widget behaviour on theme switch.
- Install and configure at least 3 plugins (SEO, contact form, and one more of choice).
- Build a custom theme from scratch: style.css, header.php, footer.php, sidebar.php, index.php, single.php, page.php.
- Implement the Loop and at least 6 different template tags across templates.
- Register a custom navigation menu and a custom widget area via functions.php.
- Create a custom shortcode and a custom filter.
- Register a Custom Post Type with a Custom Taxonomy and build its archive/single templates.
๐Exam Pattern & Model Question Paper
Based on the official Saurashtra University BCA (Honours) evaluation scheme, CS-17 carries 50 CCE (internal) + 50 SEE (semester-end) = 100 total marks. Internal/unit tests generally follow this structure (25 marks per test, covering 2โ3 units at a time):
| Question | Instruction | Marks |
|---|---|---|
| Q.1 | Attempt any TWO of the following (Unit 1) | 10 |
| Q.2 | Attempt any TWO of the following (Unit 2 / relevant unit) | 10 |
| Q.3 | Attempt any ONE of the following (Unit 3 / relevant unit) | 05 |
The Semester-End Exam (SEE) typically extends this pattern across all 5 units for the full 50 marks, mixing short-answer, descriptive, and practical/coding-based questions (writing template tag code, explaining hooks, designing a CPT, etc.).
โImportant Exam-Oriented Questions & Answers
Short Answer Type (2 marks each โ good for Q1/Q2 style)
Long Answer / Descriptive Type (5 marks each โ good for Q3 style)
Practical / Coding-Based
โกQuick-Revision Flashcards
๐Full Syllabus Summary
Unit 1 โ Introduction, Installation & Configuration
CMS/WordPress fundamentals, features, pros/cons, local & live installation, directory structure, dashboard, content (posts/pages/media), Gutenberg blocks, user roles, core settings, updates, database structure.
Unit 2 โ Theme
What a theme is, install/activate flow, and all five Customizer panels (Site Identity, Menus, Widgets, Homepage Settings, Additional CSS).
Unit 3 โ Widget & Plugin
Widgets/widget areas, widget management, inactive widgets; what a plugin is, install/activate flow, and commonly used plugins (SEO, forms, e-commerce, caching, ACF).
Unit 4 โ Theme Development
Theme anatomy, all template files, the Template Hierarchy, the Loop, and the full set of template tags (General, Author, Category, Link, Post, Post Thumbnail, Navigation Menu, Conditional) plus functions.php.
Unit 5 โ Advanced Development
Hooks (add_action/add_filter), shortcodes (add_shortcode/do_shortcode), register_nav_menu(), Custom Post Types + Taxonomies (register_post_type/register_taxonomy), and custom widget areas (register_sidebar/dynamic_sidebar).
๐References
- Sarah McHarry โ WordPress to Go: How to Build a WordPress Website on Your Own Domain, from Scratch, Even If You Are a Complete Beginner
- Official WordPress Developer Resources โ developer.wordpress.org (Theme Handbook, Plugin Handbook, Template Tag reference)
- WordPress Codex & wordpress.org documentation
- Saurashtra University B.C.A. (Honours) & B.C.A. (Honours with Research) Syllabus, Semester 3 & 4, effective June 2024