Call global variable array() in woocommerce child/template

It is all fine. You just need to declare variable global first then you can set the value of this and access globally. function my_free_shipping( $is_available ) { global $woocommerce, $product_notfree_ship; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( ‘1’, ‘2’, ‘3’, ‘4’, ‘5’ ); Then again declare it globally when using … Read more

Ajax Pagination on Ajax filter

As @Milo brilliantly pointed out, there is no such a thing like a global query object in WordPress. So I’ve solved the problem via JS, like this: var isFiltered = false; var filters; $(load_more_button).click(function(e) { load_more_handler(e); }); $(filters_form).submit(function(e) { filter_handler(e); }); function filter_handler(e) { isFiltered = true; filters = $(this).serialize(); var data = { action: … Read more

Using global $post; to get featured image for custom post via WP_Query

$port_query->the_post(); should set the $post global. That isn’t the problem. The problem is that the you are trying to use $post before your secondary Loop runs (99% sure). You’ve hooked the bkg_featured_image() function to wp_head. wp_head runs in the header of the document, which, unless you are careful, will run before the other template code. … Read more

Defining a global array in functions.php?

In order to access a variable defined in the global scope you must reference it with the global keyword wherever you want to call it again. In your case, the function create_year_terms() must call the global $year_arr within its scope. Also, you can always get your variable in the global scope by using the $GLOBALS … Read more

Cannot update custom database table row

Before trying to write to the database, always validate the values you’re putting in: $fValid = true; if ( !isset( $payment->status ) ) { echo ‘Error: Payment status is not set’; $fValid = false; } if ( !isset( $order_id ) ) { echo ‘Error: Order ID is not set’; $fValid = false; } if ( … Read more

Add classname comment template from functions.php

You should consider hooking into the comment_class() and post_class() filters, if your theme supports it. Using the comment_class filter: We can add the following filter: /** * Add a custom comment class, based on a given comment author’s user meta field. * * @see http://wordpress.stackexchange.com/a/170443/26350 */ add_filter( ‘comment_class’, function( $classes, $class, $comment_id, $post_id ) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)