WordPress.org

Ready to get started?Download WordPress

Forums

Custom Search Box - wordpress (7 posts)

  1. yuvin
    Member
    Posted 1 year ago #

    I am trying to customize my search. As I am using ticketing platform on subdomain, so I want to customize my search to search under subdomain when user hit search button.

    For example: when user hits search button I want following query string:

    subdomain.domain.com/search_kwd?=<query from searchbox>

    How can I do this?

  2. curlybracket
    Member
    Posted 1 year ago #

    Is this URL working : subdomain.domain.com/search_kwd?=<query from searchbox> ?

    I guess it should rather be
    subdomain.domain.com/?search_kwd=

    If so, you can just modify the search widget of wordpress. Modify the form action so it'll redirect you to your sudomain's search.
    form action="subdomain.domain.com/?s="

    However if you are trying to display results from your subdomain on your actual domain, this is not the way to do it.

  3. yuvin
    Member
    Posted 1 year ago #

    No i am trying to display results on sub-domain itself. So currently i have 2 files (searchform.php) and search.php. Following are codes:

    SearchForm.php
    ------
    `<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) );">
    <label for="s" class="assistive-text"><?php _e( 'Search', 'voyage' ); ?></label>
    <input type="text" class="search-query" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', 'voyage' ); ?>" />
    <input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'voyage' ); ?>" />
    </form>`
    ----------------------------------

    search.php
    --------

    <?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'voyage' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    			</header>
    
    			<?php voyage_content_nav( 'nav-above' ); ?>
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php get_template_part( 'content', 'summary' ); ?>
    
    			<?php endwhile; ?>
    
    			<?php voyage_content_nav( 'nav-below' ); ?>
    
    		<?php else : ?>
    			<?php get_template_part( 'content-none' ); ?>
    		<?php endif; ?>

    -------------

    I tried putting your code [action="subdomain.domain.com/?s="] but its still searching in main website.

  4. yuvin
    Member
    Posted 1 year ago #

    Sorry.. the sub-domain query is .... subdomain.domain.com/ResultsGeneral.aspx?stype=0&kwds=<searchterm>

  5. curlybracket
    Member
    Posted 1 year ago #

    Hm.

    So you want the results from the WordPress search on the main domain displayed on your subdomain which is not running WP

    or

    you want that when i enter a search term in WP and then hit the button i am redirected to your subdomain with my searchterm and it is your ticketing platform on which i will actually perform the search ?

  6. yuvin
    Member
    Posted 1 year ago #

    2nd option - " i enter a search term in WP and then hit the button i am redirected to your subdomain with my searchterm"

  7. curlybracket
    Member
    Posted 1 year ago #

    <form method="get" id="searchform" action="http://subdomain.domain.com/search_kwd">
    <label for="s" class="assistive-text"><?php _e( 'Search', 'voyage' ); ?></label>
    <input type="text" class="search-query" name="search_kwd" id="s" placeholder="<?php esc_attr_e( 'Search', 'voyage' ); ?>" />
    <input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'voyage' ); ?>" />
    </form>

    Something like this should work.
    Redirect the form to the other search form and submit the correct variable name.
    You will eventually need to modify the name attribute of the submit button too.

    The basic idea is that you send variables to your subdomain's search form which have the same names as what this search form actually expects.

    You could even try to copy the whole code of your subdomain to your WP template. Just make sure the form action contains the correct URL (the one of your subdomain)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.