PHP code example of grottopress / wordpress-page

1. Go to this page and download the library: Download grottopress/wordpress-page library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

grottopress / wordpress-page example snippets



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 :(';
}