Skip to:
Content
Pages
Categories
Search
Top
Bottom

WP Pages that displays a specified member directory search results

  • @jasonleedesigns

    Participant

    I am developing a nanny website and I would like to make lading pages that show a specified list of members from a selected city. For example Virginia Beach.

    I have made a WP page:
    http://totalcaregivers.com/Site/virginia-beach/

    On that page I want to display the search results that are generated from http://totalcaregivers.com/Site/members/?s=virginia+beach

    does anyone know what code I could place in the WP page that will display the search results??

    I want to make these pages for seo purposes and to entice people to sign up for the site. Each individual page of the selected city/state will have a sign up now form.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @slaffik

    Moderator

    Open members/members-loop.php file in your theme.
    Copy its code and paste into your page template file.
    Find this string in that code:
    `bp_has_members( bp_ajax_querystring( ‘members’ )`
    Change it to smth like this:
    `bp_has_members(array(‘search_terms’ => ‘virginia beach’))`

    PS Open `/buddypress/bp-members/bp-members-template.php` file, line 264, to see all possible values that you can pass to a function.

    @slaffik

    Moderator

    Take care of quotes, they were converted in a wrong way in the snippet above.

    @biswadip

    Participant

    Thank you that was very helpful.

    How do I submit a query from the members search form to bring up the appropriate listing in the manner mentioned above? At the moment I can only search for members when the search form submits to the members directory. What I want to do is that when a user submits a search query from a search form on this page:

    http://website/custom-page/

    the results from the query:

    http://website/members/?s=term-searched-for

    are displayed on the same custom page hosting the search form:

    http://website/custom-page/

    I have tried setting the search form action attribute like so:

    form action = ""

    but this creates the query:

    http://website/custom-page/?s=term-searched-for&members_search_submit=Search

    and the result is a 404 page not found.

    I have been reading in some places eg:
    here and here that buddypress redirects search queries so I need to override that redirection and I have attempted doing so without much success.

    My search form looks like this:

    	<div id="members-dir-search" class="dir-search bp-index-search" role="search">
                <?php //bp_custom_directory_members_search_form(); 
                $default_search_value = bp_get_search_default_text( 'members' );
                $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
    
                    <form action="" method="get" id="search-members-form">
                        <label><input type="text" name="s" id="members_search" placeholder="<?php echo esc_attr( $search_value ) ?>" /></label>
                        <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
                    </form>
    
    	</div>

    I check to see if the form has been submitted:

    <?php if(isset($_REQUEST ['members_search_submit'])){ ?>

    and then, following @Slave UA’s suggestion, I have copied and pasted the code from the “members-loop.php” file to my page template and I then changed

    bp_has_members( bp_ajax_querystring( 'members' )

    to

    bp_has_members(array('search_terms' => $search_term))

    If I hardcode the search term then it works but it does not seem to accept the search term submitted through the search form.

    Any help greatly appreciated.

    @biswadip

    Participant

    In the above the line
    bp_has_members(array('search_terms' => $search_term))

    is actually
    bp_has_members(array('search_terms' => $search_value))

    @biswadip

    Participant

    Thanks for your help it all works fine on Chrome and Firefox now – I was testing on IE8 as that is what our clients are using.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP Pages that displays a specified member directory search results’ is closed to new replies.
Skip to toolbar