getting error :Fatal error: Uncaught Error: Call to a member function get_queried_object() on null in wordpress - wordpress

i have hosted my wordpress site to godaddy, i have configured all the things when i open my site, i am getting this error Fatal error: Uncaught Error: Call to a member function get_queried_object() on null in wp-includes/query.php on line 46 , i checked the query.php file, there is inbuilt function
function get_query_var( $var, $default = '' ) {
global $wp_query;
return $wp_query->get( $var, $default );
}
can anyone please help me how to resolve this issue ?

Related

Disable tax to logged out users in WordPress

Someone has asked this question before, but I have tried the code and when I try to log back in via wp-admin I get unexpected error:
PHP Fatal error: Uncaught Error: Call to a member function set_is_vat_exempt() on null
Disable tax for non logged in users
Can someone help me? This is the code, I am not sure what bit is causing the error.
add_action( 'init', 'wc_tax_exempt_unlogged' );
function wc_tax_exempt_unlogged() {
// Getting user data for logged users
if( is_user_logged_in() ){
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
$current_user_roles = $current_user->roles;
$bilal_id = 0;
}
// Exempting of VAT non logged users, customers and the main admin ID (you)
if( ! is_user_logged_in() || in_array( 'customer', $current_user_roles ) || $bilal_id == $current_user_id ){
WC()->customer->set_is_vat_exempt(true);
}
}
Thanks

WordPress testing error: use of undefined constant

I sm working with a windows OS created wordpress plugin unit testing code written as below
<?php
class Test_WP_Simple_Plugin extends WP_UnitTestCase {
public function test_constants () {
$this->assertSame( 'wp-simple-plugin', WPSP_NAME ); //Error line
$url = str_replace( 'tests/phpunit/tests/', '',
trailingslashit( plugin_dir_url( __FILE__ ) ) );
$this->assertSame( $url, WPSP_URL );
}
}
that gives an error message
Use of undefined constant WPSP_NAME - assumed 'WPSP_NAME' (this will throw an Error in a future version of PHP)
please help what is wrong in this code? thanks
The issue is probably, that the WPSP_NAME variable has not been declared.

I am getting error: Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION)

My website is showing Parse error, when I tried to disable the specific plugin, the situation gets worse and starts showing error in another jetpack plugin, if I disable all plugins, the error shows in some different file. please help, my site is down for two days.
Tried disabling plugin/s, reinstalling the plugin, deleting the errror code line
/**
* Define Mega Menu constants
*
* #since 1.0
*/
private function define_constants() {
define( 'MEGAMENU_VERSION', $this->version );
define( 'MEGAMENU_BASE_URL', trailingslashit( plugins_url( 'megamenu' ) ) );
define( 'MEGAMENU_PATH', plugin_dir_path( __FILE__ ) );
}
// populate grid sub menus
if ( $item->depth === 0 && $item->megamenu_settings['type'] == 'grid' || ( $item->depth === 1 && $item->parent_submenu_type == 'tabbed' && $item->megamenu_settings['type'] == 'grid') ) {
$saved_grid = $widget_manager->get_grid_widgets_and_menu_items_for_menu_id( $item->ID, $args->menu->term_id, $items );
$next_order = $this->menu_order_of_next_sibling( $item->ID, $item->menu_item_parent, $items) - 999;
foreach ( $saved_grid as $row => $row_data ) {
$rolling_dummy_id++;
$next_order++;
Error message:
Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in /home/u912283588/domains/meersgavhb.com/public_html/wp-content/plugins/megamenu/megamenu.php on line 309
The site is experiencing technical difficulties.

After Updating wordpress theme error is coming

This error is coming: Fatal error: Call to undefined function is_wp_error() in /home/mrsjdcom/himalayantraders.in/wp-includes/load.php on line 401 how to resolve it?
When I go to cpanel code showing is
if ( is_wp_error( $prefix ) ) {
wp_load_translations_early();
wp_die(
/* translators: 1: $table_prefix 2: wp-config.php */
sprintf( __( 'ERROR: %1$s in %2$s can only contain numbers, letters, and underscores.' ),
'$table_prefix',
'wp-config.php'
Please help
Try to upload load.php file manually through FTP and check. Might be a chance of incomplete update.

Using the wordpress loop within a plugin

I'm messing with a plugin that uses the wordpress loop. I've been working on this for quite some time and can't seem to find a solution here.
Basically, I have the following functions within my plugins folder:
function fnp_getslideshow($settings) {
$query = new WP_Query( "posts_per_page=5");
while ( $my_query->have_posts() ) : $my_query->the_post();
# Code here
endwhile;
}
and
add_action( 'loop_start', 'fnp_getslideshow', 10, 1 );
For some reason, I'm getting the following error: "Fatal error: Call to a member function have_posts() on a non-object in C:\xampp\htdocs\slb\wp-content\plugins\feature-post-slideshow\fnp_functions.php on line 80". Any ideas as to what is causing this?

Resources