grottopress/wordpress-page

Get current page attributes in WordPress

v1.0.0 2023-05-31 17:19 UTC

This package is auto-updated.

Last update: 2024-04-23 14:20:47 UTC


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

  1. Fork it
  2. Switch to the master branch: git checkout master
  3. Create your feature branch: git checkout -b my-new-feature
  4. Make your changes, updating changelog and documentation as appropriate.
  5. Commit your changes: git commit
  6. Push to the branch: git push origin my-new-feature
  7. Submit a new Pull Request against the GrottoPress:master branch.