grottopress / wordpress-page
Get current page attributes in WordPress
Installs: 1 182
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
Requires (Dev)
README
Get current page attributes in WordPress.
Installation
Install via composer:
composer require grottopress/wordpress-page
Usage
<?php declare (strict_types = 1); use GrottoPress\WordPress\Page; // Instantiate $page = new Page(); // `$page` now represents the current page (where it was instantiated) // Get page title echo $page->title(); // Get page description echo $page->description(); // Get page URL echo $page->URL('full'); // Get page number echo $page->number(); // Get page type print_r($page->type()); // Check if page is single post if ($page->is('single')) { echo 'Single!'; } else { echo 'Not single :('; } // Check if page is 'tutorial' custom post archive if ($page->is('post_type_archive', 'tutorial')) { echo 'Yay!!! Tutorials.'; } else { echo 'Nope :('; }
Development
Run tests with composer run test
.
Contributing
- Fork it
- Switch to the
master
branch:git checkout master
- Create your feature branch:
git checkout -b my-new-feature
- Make your changes, updating changelog and documentation as appropriate.
- Commit your changes:
git commit
- Push to the branch:
git push origin my-new-feature
- Submit a new Pull Request against the
GrottoPress:master
branch.