modifying every other element’s class inside while loop

<?php $homePosts = new WP_Query(array( ‘posts_per_page’ => 5 )); $count = 1; while ($homePosts->have_posts()) { $homePosts->the_post(); if ( $count % 2 == 0 ) { $class=”right”; } else { $class=”left”; } ?> <section class=”align-<?php echo $class; ?>” > <div class=”content”> <?php the_title(); ?> <?php the_content(); ?> </div> </section> <?php $count++; } wp_reset_postdata(); ?> You can … Read more

how to increase connection time

Maybe your hook called too early. And after yours, this connection time changes elsewhere. Try to increase priority like that: add_filter( ‘auth_cookie_expiration’, ‘keep_me_logged_in’, 99, 3); function keep_me_logged_in( $expiration, $user_id, $remember ) {/*your code*/}

I’m creating a online store for my website, my aim is to add description to products in home page only how can i achieve it?

You can use is_front_page() function in your code. add_action(‘woocommerce_after_shop_loop_item_title’, ‘description_in_shop_loop_item’, 3 ); function description_in_shop_loop_item() { global $product; if( is_front_page()) { // HERE define the number of words $limit = 10; $description = $product->get_description(); // Product description // or // $description = $product->get_short_description(); // Product short description // Limit the words length if (str_word_count($description, 0) > … Read more

Extend WordPress Audio Widget to accept HLS (.m3u8) URLs

There is a filter, wp_audio_extensions, that should allow you to add m3u8 to the whitelist of allowed file extensions. Add this code to a child theme’s functions.php file, or using a plugin like Code Snippets: function wpse_341199_allow_m3u8_extension( $exts ) { $exts[] = ‘m3u8’; return $exts; } add_filter( ‘wp_audio_extensions’, ‘wpse_341199_allow_m3u8_extension’ );

function class doesnt work

To override the default styles you have to use more specific selectors. #wpadminbar .my_menu_item_class { background: yellow; } #wpadminbar .menupop.hover ul li.my_menu_item_class > a { color:red; }