How to separate post titles with a comma in the loop?

Instead of outputting everything immediately, save it to a variable so you can conditionally add a comma (and presumably a space) between items: <?php // The Loop if ( $query->have_posts() ) { // Save the number of posts found global $wp_query; $total_posts = $wp_query->post_count; // Set a counter variable $i=0; while ( $query->have_posts() ) { … Read more

How to use single.php output in function.php

I don’t undesrtand well what you want to do. You mean this??? (the last line): <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, get_post_format() ); ?> $content = get_the_content(); $content = apply_filters(‘the_content’, $content); echo wp_strip_all_tags($content); $Temp_text=wp_strip_all_tags($content); do_something($Temp_text); ?> And implement do_something() inside functions.php

Custom Loop.php having a loop inside a loop

Changes it so it works. <?php $i = 1; $icount = 1; ?> <?php while ( have_posts() ) : the_post(); if ($icount < 11) { if ($i % 5 == 0) { echo ‘<div class=”col5x2″>’; include ‘modules/projects/small-square.php’; echo ‘</div>’; $i = 1; $icount++; continue; } if($i % 2 == 1): echo ‘<div class=”col5″>’; endif; include … Read more

Adding new divs with custom classes to products on WooCommerce shop page [closed]

Why not edit the template file instead of using hooks? https://github.com/woocommerce/woocommerce/blob/3.8.0/templates/content-product.php This template can be overridden by copying it to yourtheme/woocommerce/content-product.php. A small example <li <?php wc_product_class( ”, $product ); ?>> <div class=”col-md-5 offset-md-1″> <?php /** * Hook: woocommerce_before_shop_loop_item. * * @hooked woocommerce_template_loop_product_link_open – 10 */ do_action( ‘woocommerce_before_shop_loop_item’ ); /** * Hook: woocommerce_before_shop_loop_item_title. * * … Read more

How set a while with a function

a. from the return function dosome(){ return true; } OR function dosome( param = true ){ return param; } var = dosome(); while ( var ){ need(); } b. while loop from fixed param TRUE function need( $param = true) { while ( param ){ $updates = get_point(); echo $updates[‘selector’]; echo ‘done’; } } need(); … Read more