---
title: "How to check the current request context in WordPress?"
author: "Lax Mariappan"
date: "2023-12-12"
categories: ["WordPress"]
excerpt: "The wp-context package allows you to determine the current request's context easily."
canonical_url: "https://laxmariappan.com/how-to-check-the-current-request-context-in-wordpress/"
---

# How to check the current request context in WordPress?

The wp-context package allows you to determine the current request’s context easily.

Install the package and instantiate the WpContext class.

Then you can check the context using WpContext::is() method.

Here is an example:

<?php
use Inpsyde\WpContext;

// Instantiate the class
$context = WpContext::determine();

// Use the WpContext::is() method to check context
if (!$context->is(WpContext::FRONTOFFICE, WpContext::BACKOFFICE)) {
    return false;
}Code language: HTML, XML (xml)

https://gist.github.com/laxmariappan/12fba7f207b85b8857bd62a0f50bb61f