Call header of wordpress project theme in a template page created in custom plugin in wordpress

My plugin main file(Plugin.php)
The display page which I have made is inside this plugin only named as shopdetail.php and in that i have included

Read More
<?php
/*
  Plugin Name: Coupon  
  Version: 1.0.0
  Author: Akash Rai
  Description: This plugin is for Coupon Management
*/
session_start();
ob_start();
include_once dirname(__FILE__) . '/includes/coupon_shortcodes.php';
function coupon_plugin()
{
    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');		
}
$url = $_SERVER['REQUEST_URI'];
$product = substr($url,19);
if($url == "/preview/cash-back/$product" && $url != "/preview/cash-back/")
{
        load_template( dirname( __FILE__ ) . 'includestemplatesshopdetail.php');
        exit();
}
register_activation_hook( __FILE__, 'coupon_plugin' );              

When I run the page it says:-

Fatal error: Call to a member function get() on null in C:xampphtdocspreviewwp-includesquery.php on line 28
I have created a custom plugin and in that plugin I have created a custom php page in which I am showing my description coming from database, but the problem is when I use get_header(); function then it does not display header of the main theme which I have implemented in project. Can anyone help me with it, I am little bit newbei

Related posts

Leave a Reply

1 comment

  1. At the start of your plugin code try adding

    global $wp_query;
    

    If it still does the same error, underneath it add

    var_dump($wp_query)
    

    If that is returning as null, then for some reason your plugin isn’t accessing wp_query, which is what is needed for get() I believe.