Get category slug of the Parent category of a Product

Put this below code in functions.php and Try it. add_action( ‘woocommerce_before_single_product’, ‘content_before_addtocart_button’ ); function content_before_addtocart_button() { global $post; $categories = array(); $taxonomies = get_terms( array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false, ‘parent’ => 0 )); if ( !empty($taxonomies) ) : foreach( $taxonomies as $taxonomy ) { $categories[] = $taxonomy->slug; } endif; $terms = get_the_terms( $post->ID, … Read more

Display articles with a different template in the home page | Solved |

I haven’t tested this, but it looks like you just need to set an iteration variable (usually abbreviated $i), like this: <?php $i = 0; // This sets your variable $query = [ ‘post_type’ => ‘post’, ‘posts_per_page’ => 5 ]; $query = new WP_Query($query); while ($query->have_posts()) : { $query->the_post(); if($i == 0) : get_template_part(‘loops/acc-cards’); else() … Read more

How to display 8 posts in four columns and 2 rows on a carousel slide?

Its very difficult to understand from the HTML code example what you are trying to achieve but going by the php you could do the following. <?php $posts = new WP_Query([ ‘post_type’ => ‘services’, ‘posts_per_page’ => -1, ‘order’ => ‘ASC’ ]); if ($posts->have_posts()) : ?> <ul class=”slider-container”> <?php $loop_position = 1; while ($posts->have_posts()) { $posts->the_post(); … Read more