Support

Account

Home Forums Front-end Issues Order search results by last name

Helping

Order search results by last name

  • Tried this code for form:

    function jma_practitioner_form() {
        $form = '<form method="get" action="' . home_url( '/' ) . '">
    		<div class="input-group" style="max-width: 250px">
    			<input type="text" class="form-control search-input" name="s" placeholder="Practitioner Search" />
    			<input type="hidden" name="post_type" value="practitioner" />
    			<input type="hidden" name="meta_key" value="last_name" />
    			<input type="hidden" name="orderby" value="meta_value_num" />
    			<input type="hidden" name="order" value="ASC" />
    			<span class="input-group-btn">
    				<button class="btn btn-default" type="submit" style="padding: 6px 15px;">
    					<i class="fa fa-search"></i>
    				</button>
    			</span>
    		</div>
    	</form>';
    
        return $form;
    }
    add_shortcode( 'practitioner_search', 'jma_practitioner_form' );

    The search functionality works and it is limited to my custom post type, but ordering doesn’t work.
    thx,
    John

  • Hi @johnnya23

    You code seems just fine.
    Were you able to find the problem or are you still having a problem?

    Kindly let me know so that I may be able to help further.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.