Return to the beginning of the results of a for loop

You can instantly access any position in an array by specifying the index. i.e. to get the first element of the $search_results array: $first_result = $search_results[0]; Note if you’re not used to working with arrays, they are “0” indexed in most languages, which means the first element’s index is 0, the second is 1, etc. … Read more

Remove generated category and tag class names from woocommerce product & blog listings markup

You have to leverage the woocommerce wc_product_post_class filter. The following code should do the trick. function my_strip_tag_class( $classes ) { global $post; $product_tags = get_the_terms( $post->ID, ‘product_tag’ ); if( $product_tags ) foreach ( $product_tags as $tag ) { $tag_index = array_search($tag, $classes); if($tag_index !== false){ unset($classes[$tag_index]); } } return $classes; } add_filter( ‘wc_product_post_class’, ‘my_strip_tag_class’ );

i want add conditional for add category in wordpress

If I understood your question correctly, then something like this might do the trick. // html markup for the selects <select name=”main_cat”> <option value=”A”>A</option> <option value=”B”>B</option> </select> <select name=”sub_cat_for_A” class=”sub-cat-select hidden”> <option value=”C”>C</option> <option value=”D”>D</option> <option value=”E”>E</option> </select> <select name=”sub_cat_for_B” class=”sub-cat-select hidden”> <option value=”F”>F</option> <option value=”G”>G</option> <option value=”H”>H</option> </select> If you change your mind and … Read more

PHP 7.2 Challenge

If you can install and run phpcs from the command line, you can try adding the PHPCompatibility library and running it to generate a report. Examples This will help identify potential issues. If that’s not possible, there’s a plugin that will help check your site for PHP compatibility issues called the PHP Compatibility Checker. It … Read more

PHP Error in WordPress Theme

Replcace this function start_el(&$output, $item, $depth, $args) { …. with this function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { …. I hope this will work.

Replacing entire tag with shortcode – JavaScript [duplicate]

This looks like javascript. do_shortcode is a php function. I’m not sure the full context, but at the very least, you need to wrap your php function in php tags like this and add an echo: <?php // Start of php file ?> <script> var stockcounter = document.getElementsByClassName(“stock in-stock”); if(stockcounter[0].innerHTML==’0 in stock’) { //Displays timer … Read more