0

Created a very simple plugin to display a custom search form. No errors, but not performing search. I may be over my head and leaving out one or many requirements.

My plugin code:

/**
 * Begin Shortcode.
 */
function divilicious_micro_search($atts, $content = null) {
   extract(shortcode_atts(array('color' => 'teal'), $atts));

   return '<div id="dlms">
            <form role="search" method="get" action="' . home_url( '/' ) . '"  class="dlms">
              <input type="search" class="dlms-search-input" placeholder="'.esc_attr__('Search...','dlms').'" value="'.get_search_query().'" name="s" title="Search for:" >
              '.get_search_query().'
              <button style="background:'.$color.'" type="submit">
                <span class="fontawesome-search"></span>
              </button>
            </form>
        </div>';
}

add_shortcode('dl-micro-search', 'divilicious_micro_search');

Am I missing something that will give me a fighting chance or shall I give up?

3
  • Highlight your code in editor and then click the {} sign above the editor. Or simply indent each line with 4 spaces. This will all display your code in a code block Commented Oct 26, 2015 at 14:26
  • Works for me. Please try to describe your problem in more detail.
    – s_ha_dum
    Commented Oct 26, 2015 at 14:29
  • Here is my test page. Click the orange icon to open, enter your search term and see what happens (or not). divilicious.com/a-micro-search-plugin-shortcode-test-page Commented Oct 26, 2015 at 14:35

1 Answer 1

0

You aren't executing the shortcode. The raw text is simply being echoed to the page. I don't know why, but I assume you've just written something like [ dl-micro-search color="hex or named color" ] into the source when you should have echo do_shortcode('[ dl-micro-search color="hex or named color" ]'); instead.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.