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 );

Filter content in shortcode

The year attribute you added to shortcode [speaker_overview_2017 year=2017] will be available through $atts in this way $atts[‘year’]. I assume, you want to do a meta query and the key is speakers_jaar and the value will be $atts[‘year’]. Please check the following code. When a year is set in shortcode, query will be limited to … Read more

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