Title: Content inside custom Loop not working
Last modified: April 13, 2023

---

# Content inside custom Loop not working

 *  [linjo13](https://wordpress.org/support/users/linjo13/)
 * (@linjo13)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/)
 * Ive written a custom template and custom query to fetch products. Ive added a
   text(an array has been printed) in the template( inside the loop). But in the
   second page(when the infinite scrolling triggers) the text is not showing .
 * May I know why this happen?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcontent-inside-custom-loop-not-working%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [Pablo Pérez](https://wordpress.org/support/users/pperez001/)
 * (@pperez001)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16656076)
 * Hi there,
 * I checked your page but I can’t see our plugin working in your site. Is it possible
   for us to replicate your issue in your site? Also if it is possible share with
   a screenshot of the selectors in the plugin.
 * Have a great day.
 *  Thread Starter [linjo13](https://wordpress.org/support/users/linjo13/)
 * (@linjo13)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16664329)
 * [@pperez001](https://wordpress.org/support/users/pperez001/) Hello,
 * I am using the YITH infinite scrolling plugin you can scroll down for the next
   page to load(via the plugin ) and you can see that.
 * To make the issue more clearer, I’ve printed a “hai” inside the template, the
   hai is printing in the first page but not from the 2nd page(when the yith scrolling
   plugin comes into play.
 * Please check this [link ](https://bluerose.in/br-category/?f_term=artificial-roses&fdbislemm)
   to see whats happening
 * Ive echoed the “hai” just before the wc_get_template_part( ‘content’, ‘product’)
 * Please check the screenshot for a better understanding.
 * > [View post on imgur.com](https://imgur.com/a/f8gtXCR)
 * Please let me know how we can get the “hai” printed before the loop template 
   part.
    -  This reply was modified 3 years, 1 month ago by [linjo13](https://wordpress.org/support/users/linjo13/).
 *  [Iván Sosa](https://wordpress.org/support/users/ivansosa/)
 * (@ivansosa)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16667678)
 * Hi there,
 * you need to print that content inside the content-product.php file of your current
   theme.
 * Usually, the theme should use a hook to print this custom code.
 * You could try to add this custom code in the functions.php of your theme:
 *     ```wp-block-code
       add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_before_shop_loop_item_custom' );
   
       function woocommerce_before_shop_loop_item_custom() {
           echo 'hai';
       }
       ```
   
 * Could you try it, please?
 * Have a nice day!
 *  Thread Starter [linjo13](https://wordpress.org/support/users/linjo13/)
 * (@linjo13)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16670988)
 * [@ivansosa](https://wordpress.org/support/users/ivansosa/) Yes I got that, but
   I need the “hai” to be printed just before the li(pls refer the screenshot). 
   What I am looking here is to print a category title before each group of items(
   so that it should be printed before li tag). Please guide
 * > [View post on imgur.com](https://imgur.com/a/wowS47W)
 * 
   Thanks
 *  [Iván Sosa](https://wordpress.org/support/users/ivansosa/)
 * (@ivansosa)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16675929)
 * Hi there,
 * unfortunately, at the moment is not possible. Another way to do it is to use 
   the solution I gave you previously and move all these elements to each parent
   element via JS.
 * I hope it helps you.
 * Have a nice day!
 *  Thread Starter [linjo13](https://wordpress.org/support/users/linjo13/)
 * (@linjo13)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16675963)
 * [@ivansosa](https://wordpress.org/support/users/ivansosa/) Okay, thanks for the
   reply. I will try that way with JS then. Hope you will consider this scenario
   as well in the next updates.
 *  Thread Starter [linjo13](https://wordpress.org/support/users/linjo13/)
 * (@linjo13)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16677611)
 * [@ivansosa](https://wordpress.org/support/users/ivansosa/) Can you pls guide 
   where should I call my custom js? Like when the ajax for the next page load triggers?
   May I know where is that script?
 *  [crodriguez1991](https://wordpress.org/support/users/crodriguez1991/)
 * (@crodriguez1991)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16680469)
 * Hello there,
 * I hope you’re doing well :D.
 * I think you can use the following JS trigger
 *     ```wp-block-code
       yith_infs_added_elem
       ```
   
 * For example you can use it in the following way
 *     ```wp-block-code
       jQuery(document).on( 'yith_infs_added_elem', function(){
   
        // show arrow up
   
       } );
       ```
   
 * At the moment this is the trigger after the elements are added to the page.
 * I hope it helps you.
 * Have a good day.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Content inside custom Loop not working’ is closed to new replies.

 * ![](https://ps.w.org/yith-infinite-scrolling/assets/icon.svg?rev=3303151)
 * [YITH Infinite Scrolling](https://wordpress.org/plugins/yith-infinite-scrolling/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-infinite-scrolling/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-infinite-scrolling/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-infinite-scrolling/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-infinite-scrolling/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-infinite-scrolling/reviews/)

 * 8 replies
 * 4 participants
 * Last reply from: [crodriguez1991](https://wordpress.org/support/users/crodriguez1991/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/content-inside-custom-loop-not-working/#post-16680469)
 * Status: not resolved