PHPackages                             centrid/wpoow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. centrid/wpoow

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

centrid/wpoow
=============

WordPress Object Oriented Wrapper

2.1.0(2y ago)44141[15 issues](https://github.com/walisc/WPooW/issues)[1 PRs](https://github.com/walisc/WPooW/pulls)GPL-3.0PHP

Since Oct 31Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/walisc/WPooW)[ Packagist](https://packagist.org/packages/centrid/wpoow)[ RSS](/packages/centrid-wpoow/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (9)Used By (0)

Wordpress Object Oriented Wrapper
=================================

[](#wordpress-object-oriented-wrapper)

#### An OOP Wordpress wrapper for rapid development

[](#an-oop-wordpress-wrapper-for-rapid-development)

If you have had to create a custom theme/plugin in WordPress (which requires quite a bit of configuration), you know this can be quite cumbersome. This wrapper aims to simplify this process by providing an object-oriented library which abstracts most of the tasks associated with this. Below is a simple example showing you how you can easily create a Custom [PostType](https://codex.wordpress.org/Post_Types) using this wrapper.

```
//functions.php

include 'wpAPI/wpAPI.php';

$WPooW = new wpAPI();
$bookReviewPostType = $WPooW->CreatePostType("_bookReview", "Book Review", true);

$bookReviewPostType->AddField(new Text("_bookTitle", "Book Title"));
$bookReviewPostType->AddField(new Text("_bookAuthor", "Book Author"));
$bookReviewPostType->AddField(new Uploader("_bookImage", "Book Image"));
$bookReviewPostType->AddField(new MultiSelect("_bookCategories", "Categories", ["Philosophy" => "Philosophy", "Auto-Biography" => "Auto-Biography", "Fiction" => "Fiction"]));
$bookReviewPostType->AddField(new RichTextArea("_mySummary", "My Summary"));
$bookReviewPostType->AddField(new Text("_myRating", "My Rating"));

$bookReviewPostType->Render();
```

This will create a custom page (available via wp-admin). See below:-

[![intro_images](https://camo.githubusercontent.com/4c654d027db3556bea35abbdac2754f8593233ba59cb1827a8d52b06c13afa98/687474703a2f2f77706f6f772e646576636869642e636f6d2f696d616765732f696e74726f5f6f75747075745f696d6167655f696e7075742e706e67)](https://camo.githubusercontent.com/4c654d027db3556bea35abbdac2754f8593233ba59cb1827a8d52b06c13afa98/687474703a2f2f77706f6f772e646576636869642e636f6d2f696d616765732f696e74726f5f6f75747075745f696d6167655f696e7075742e706e67)

*Fig1: Grid Layout of new custom type*

[![intro_images_expanded](https://camo.githubusercontent.com/091c29e8bdad1aff3bd26ed6442705f2d7340d80c5244829f3f1e24f4c33e6b1/687474703a2f2f77706f6f772e646576636869642e636f6d2f696d616765732f696e74726f5f6d61696e5f696d6167655f657870616e6465642e706e67)](https://camo.githubusercontent.com/091c29e8bdad1aff3bd26ed6442705f2d7340d80c5244829f3f1e24f4c33e6b1/687474703a2f2f77706f6f772e646576636869642e636f6d2f696d616765732f696e74726f5f6d61696e5f696d6167655f657870616e6465642e706e67)

*Fig2: Adding new custom type*

To access the data added through the custom PostType, you can use a traditional WordPress query ([`WP_QUERY`](https://codex.wordpress.org/Class_Reference/WP_Query) ) by referencing your declared PostType id (in the case above, it will be `_bookReview`). WPooW however, provides a wrapper class which makes it easier to access this data. An example of how you would fetch this data using the WPooW library is below:-

```

	.book_block{
		display: inline-block;
	}
	.book_img{
		float: left;
		width: 50%;
	}
	.book_img  img{
		height: 200px;
		width: auto;
	}

	.book_details {
		float: right;
		width: 45%;
		padding-left: 2%;
	}

	.book_details p {
		font-size: 14px;
		margin-bottom: 2px;
		margin-top: 2px;
		color: white;
	}
