wpscholar/wp-context

A WordPress context library based on WordPress' built-in template hierarchy.

1.1 2020-03-18 19:22 UTC

This package is auto-updated.

Last update: 2024-04-19 05:21:05 UTC


README

A WordPress context library based on WordPress' built-in template hierarchy.

What It Does

Designed to be used after the main WordPress query has run, this context library will return an array of slugs representing the current context.

How to Use It

  1. Add to your project via Composer:
$ composer require wpscholar/wp-context
  1. Make sure you have added the Composer autoloader to your project:
<?php 

require __DIR__ . '/vendor/autoload.php';
  1. Call the static method for fetching context:
<?php

use wpscholar\WordPress\Context;

$context = Context::getContext();