Open and closed function [closed]

$open = “our lines are open”; $closed = “our lines are closed”; if ( time() >= strtotime( ’09:00:00′ ) && time() <= strtotime( ’17:00:00′ ) ) { echo $open; } else { echo $closed; } Somethinh like this should help you.

How to hide specific categories from contributors

You’ll have to change see_special_cats to something fitting. As you want to exclude contributors, but allow all others, you could use publish_posts (See the codex for all capabilities of contributors). Your code should be something like add_filter(‘list_terms_exclusions’, ‘yoursite_list_terms_exclusions’, 10, 2); function yoursite_list_terms_exclusions( $exclusions, $args ) { global $pagenow; if (in_array($pagenow,array(‘post.php’,’post-new.php’)) && !current_user_can(‘publish_posts’)) { $exclusions = … Read more

Include js script ONLY on woocommerce product category pages? [closed]

Use wp_unqueue_script for including scripts. Last parametr true include this script in footer. And woocommerce has condotions functions. You need is_product_category() or WordPress default condition is_tax(‘product_cat’). This code should work for you: function read_more_js() { if ( is_product_category() ) { wp_enqueue_script( ‘load-more-js’, esc_url( get_template_directory_uri() ) . ‘/js/read-more.js’, array( ‘jquery’ ), null, true ); } } … Read more

Issue replacing forward slash in string

I figured out a solution! Not that it explains some of the weird str_replace activity that I was seeing, so if anyone can explain that please do. But to get around the original issue I was experiencing – The line $filepath = str_replace($site_url.”https://wordpress.stackexchange.com/”, ”, $attachment->image_src_large[0]); was only having an effect on either back or front … Read more

PHP code inside Shortcode

get_field returns a value, whereas the_field echos it. You need the value to be returned into your shortcode string so do_shortcode() can read and process it. Also you need to escape the double quotes or use single quotes on fileurl= “” So, assuming preview is just the URL (and not a full HTML link) – … Read more

Menu Custom Data Attributes

If you want to add a custom data attributes to the menu that’s generated by wp_nav_menu function. You can use the nav_menu_link_attributes filter to add the desired attributes to the <a> elements. function add_menu_atts( $atts, $item, $args ) { $atts[‘data-hover’] = $atts[‘title’]; // add data-hover attribute return $atts; } add_filter( ‘nav_menu_link_attributes’, ‘add_menu_atts’, 10, 3 );

Will I have problem with PHP 5.5 and WordPress 4.9.4?

No, you will not face any problem because of PHP 5.5. WordPress recommends (not required or mandatory) PHP 7.2 because it has better performance than the older versions. If you need better performance than PHP 5.5 then you should definitely use PHP 7.2. Btw, WordPress even smoothly works with PHP 5.2.4!.

Dropdown menu for categories

This will give you your desired result. <?php $list_categories = get_categories( $args ); echo “<div class=”container”>”; echo “<div class=”productsubmenu”>”; echo “<ul>”; foreach ($list_categories as $cat) { if($cat->category_parent == 0) { $category_id = $cat->term_id; echo ‘<li class=”parent ‘.$my.’ “><a href=”‘.get_term_link( $cat ) . ‘”>’.$cat->name.'</a>’; $args2 = array( ‘taxonomy’ => $taxonomy, ‘child_of’ => 0, ‘parent’ => $category_id, … Read more