Title: PHP function in Repeater Templates
Last modified: August 24, 2020

---

# PHP function in Repeater Templates

 *  Resolved [niklaslazinbee](https://wordpress.org/support/users/niklaslazinbee/)
 * (@niklaslazinbee)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/php-function-in-repeater-templates/)
 * Is it possible to use a php function in the repeater template?
 * The following seems not to work
 *     ```
       <?php
       	function test(){
       		// do nothing
       	};
       ?>
       <li class="alm-item<?php if (!has_post_thumbnail()) { ?> no-img<?php } ?>">
          <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
       </li>
       ```
   
 * No posts will be displayed?

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

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/php-function-in-repeater-templates/#post-13304693)
 * [@niklaslazinbee](https://wordpress.org/support/users/niklaslazinbee/) Yes, that
   should work assuming the test() function is loaded and accessible gloabally.
 *  Thread Starter [niklaslazinbee](https://wordpress.org/support/users/niklaslazinbee/)
 * (@niklaslazinbee)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/php-function-in-repeater-templates/#post-13307106)
 * Strange, for me this does not work, the test() function is directly in the template
   field in the backend, so it should be available.
 * My solution is: I have created a plugin and put the functions there, now I can
   call them in the repeater template.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/php-function-in-repeater-templates/#post-13319937)
 * Ok, well not ideal but I’m glad to hear you solved it.

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

The topic ‘PHP function in Repeater Templates’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [repeater](https://wordpress.org/support/topic-tag/repeater/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 3 replies
 * 2 participants
 * Last reply from: [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/php-function-in-repeater-templates/#post-13319937)
 * Status: resolved