Title: Search Results getting a PHP Error
Last modified: August 30, 2016

---

# Search Results getting a PHP Error

 *  [robertallen](https://wordpress.org/support/users/robertallen/)
 * (@robertallen)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/search-results-getting-a-php-error/)
 * Hi all,
 * I’m getting an error on the search results page.
 * Here is my code:
 *     ```
       <?php echo do_shortcode('[ajax_load_more repeater="template_3" post_type="post" preloaded="true" preloaded_amount="10" posts_per_page="10" max_pages="0" search="'. $term .'" button_label="Show More Stories"]'); ?>
       ```
   
 * The error I get is this:
    Notice: Undefined variable: term in /home/kaleidicostudios/
   public_html/wor/wp-content/themes/_m/search.php on line 18
 * [https://wordpress.org/plugins/ajax-load-more/](https://wordpress.org/plugins/ajax-load-more/)

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

 *  [WebAssembler](https://wordpress.org/support/users/webassembler/)
 * (@webassembler)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/search-results-getting-a-php-error/#post-6391333)
 * Where are you filling the $term variable? Can you paste the entire code?
 *  Thread Starter [robertallen](https://wordpress.org/support/users/robertallen/)
 * (@robertallen)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/search-results-getting-a-php-error/#post-6391370)
 * Sure thing…
 *     ```
       <?php
       /**
        * The template for displaying search results pages.
        *
        * @package _s
        */
   
       get_header(); ?>
   
       <div id="hash-tag-header">
       	<h1>Search Results for:</h1>
       </div>
   
       <div class="centered cf">
   
       	<div id="tag-post-list">
           	<ul>
               	<?php echo do_shortcode('[ajax_load_more repeater="template_3" post_type="post" preloaded="true" preloaded_amount="10" posts_per_page="10" max_pages="0" search="'. $term .'" button_label="Show More Stories"]'); ?>
               </ul>
           </div>
   
       </div>
   
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/search-results-getting-a-php-error/#post-6391382)
 * WebAssembler is right, you need to set $term.
 *     ```
       <?php $term = $_GET['s']; ?>
       ```
   

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

The topic ‘Search Results getting a PHP Error’ 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

 * [php-error](https://wordpress.org/support/topic-tag/php-error/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 3 replies
 * 3 participants
 * Last reply from: [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/search-results-getting-a-php-error/#post-6391382)
 * Status: not resolved