Hot answers tagged

2

human_time_difference() will not work here as it returns a string in a human readable form. However, we can use some of the logic used there to construct a workable function You can try the following: (Untested) function get_custom__time_diff() { global $post; // Get the current time $current_time = time(); // Get the post date ...


1

Looks like you are just missing a "." to concatenate the string and variable. It should read: echo '$' . $price;


1

Here you go: According to documentation of get_post_meta , It will return a single value if the third parameter is true. It should be false to return an array. <?php $price = get_post_meta(get_the_ID(),'si-price'); foreach ($price as $element) { if (is_numeric($element)) { echo '$' . $element; } else { ...


1

I have solved my problem by adding $myCode -> change_url(); and add_action('wp_head', array($myCode, 'print_header_scripts')); <?php class some_code { function change_url() { $domain_name = $_SERVER['SERVER_NAME']; $country_code = get_country_code(); if ($country_code == "PK") { header("location: ...


1

ohwild_entry_meta_header() is missing the closing }.


1

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 ...


1

Well, you wouldn't need a walker for that, if it's simply adding a data attribute or something like that you could just use the items_wrap parameter. View wp_nav_menu() in Resources: $items_wrap = '<div class="top-nav" mine="something">'; $items_wrap .= '<ul id="%1$s" mine="something2" class="nav %2$s">%3$s</ul>'; $items_wrap .= ...


1

wp_logout is being triggered server side when the user is logging out, but the fact that it is being triggered do not indicate that there is a browser on the other side that actually triggered it. For example a user might log out via Ajax and then the JS code will not be evaluated. In any case, it is much better to define a logged out user as one that do ...



Only top voted, non community-wiki answers of a minimum length are eligible